Programming Articles

Page 940 of 2547

How to pass the address of structure as an argument to function in C language?

Bhanu Priya
Bhanu Priya
Updated on 15-Mar-2026 675 Views

Passing the address of a structure as an argument to a function allows the function to access and modify the original structure through a pointer. This technique is memory-efficient and enables direct manipulation of structure members. Syntax return_type function_name(struct structure_name *pointer_variable); Key Points The address of the structure is passed as an argument to the function. It is collected in a pointer to structure in function header. Advantages No wastage of memory as there is no need of creating a copy again No need of returning the values back ...

Read More

How to pass individual members of structure as arguments to function in C language?

Bhanu Priya
Bhanu Priya
Updated on 15-Mar-2026 1K+ Views

In C programming, you can pass individual members of a structure as arguments to functions. This approach treats each structure member as a separate parameter, allowing functions to work with specific data fields independently. Syntax functionName(structure_variable.member1, structure_variable.member2, ...); Key Points Each member is passed as an individual argument in the function call Structure members are collected as ordinary variables in the function header This method passes values by copy, not by reference Example: Calculating Student Total Marks Here's how to pass individual structure members to calculate total marks for students ...

Read More

Explain string library functions with suitable examples in C

Bhanu Priya
Bhanu Priya
Updated on 15-Mar-2026 41K+ Views

The C standard library provides several predefined functions for string manipulation in the string.h header file. These functions help perform operations like copying, comparing, concatenating, and searching strings efficiently. Common String Functions strlen() − finds string length strcpy() − copies strings strcat() − concatenates strings strcmp() − compares strings strstr() − searches for substrings The strlen() Function The strlen() function returns the number of characters in a string, excluding the null terminator. Syntax size_t strlen(const char *str); Example #include #include int main() { ...

Read More

How to create a pointer for strings using C language?

Bhanu Priya
Bhanu Priya
Updated on 15-Mar-2026 2K+ Views

In C programming, you can create pointers to strings using arrays of pointers. An array of pointers to strings is an array where each element is a pointer that holds the base address of a string literal or character array. Syntax char *array_name[size] = {"string1", "string2", "string3", ...}; Here, each element array_name[i] is a pointer to the base address of the corresponding string. char *names[3] = {"Alice", "Bob", "Charlie"}; names[0] names[1] ...

Read More

How to pass individual elements in an array as argument to function in C language?

Bhanu Priya
Bhanu Priya
Updated on 15-Mar-2026 2K+ Views

In C programming, you can pass individual array elements as arguments to functions by specifying the array element with its index in the function call. The function receives these elements as separate parameters, not as an array. Syntax functionName(array[index1], array[index2], ...); Example 1: Passing First and Last Elements This example demonstrates how to pass the first and last elements of an array to a function − #include void display(int first, int last) { printf("First element = %d", first); printf("Last element = %d", ...

Read More

What are the scope rules to functions in C programming?

Bhanu Priya
Bhanu Priya
Updated on 15-Mar-2026 700 Views

Scope rules in C programming define where variables and functions can be accessed within a program. These rules determine the visibility and lifetime of variables based on where they are declared. Syntax /* Global scope */ data_type variable_name; function_name() { /* Local scope */ data_type variable_name; } Local Scope Local scope specifies that variables defined within a block are visible only in that block and invisible outside the block. These variables exist only during the function execution. Global Scope Global scope specifies that ...

Read More

What are the different types of functions in C Programming?

Bhanu Priya
Bhanu Priya
Updated on 15-Mar-2026 14K+ Views

Functions in C programming are broadly classified into two types which are as follows − Predefined functions User-defined functions Predefined (or) Library Functions Predefined functions are already defined in the system libraries. These functions allow programmers to reuse existing code, which helps write error-free programs efficiently. The user must be aware of the syntax and header file required for each function. These functions are pre-written and tested by system developers They are available in standard library header files like stdio.h, math.h, string.h Programmer needs to include the appropriate header file to use them ...

Read More

How to write a C program to find the roots of a quadratic equation?

Bhanu Priya
Bhanu Priya
Updated on 15-Mar-2026 156K+ Views

A quadratic equation is of the form ax² + bx + c = 0, where a, b, and c are coefficients and a ≠ 0. The roots can be found using the quadratic formula, and the nature of roots depends on the discriminant value. Syntax r1 = (-b + sqrt(discriminant)) / (2 * a); r2 = (-b - sqrt(discriminant)) / (2 * a); Mathematical Formula The quadratic formula is − r₁ = (-b + √(b² - 4ac)) / (2a) r₂ = (-b - √(b² - 4ac)) / (2a) Where the discriminant (d) ...

Read More

Convert vowels from upper to lower or lower to upper using C program

Bhanu Priya
Bhanu Priya
Updated on 15-Mar-2026 2K+ Views

In C programming, we can convert vowels in a string from uppercase to lowercase or lowercase to uppercase using character manipulation functions. This involves checking each character to identify vowels and then applying the appropriate case conversion. Syntax #include int toupper(int c); // Converts to uppercase int tolower(int c); // Converts to lowercase Method 1: Convert Lowercase Vowels to Uppercase This approach converts all lowercase vowels (a, e, i, o, u) to their uppercase equivalents while keeping other characters unchanged − #include #include ...

Read More

C Program to find the given number is strong or not

Sindhura Repala
Sindhura Repala
Updated on 15-Mar-2026 44K+ Views

A strong number is a number where the sum of the factorial of its digits equals the number itself. For example, 145 is a strong number because 1! + 4! + 5! = 1 + 24 + 120 = 145. Syntax int factorial(int n); int isStrongNumber(int num); Understanding Strong Numbers Let's examine some examples to understand the concept better − 145 = 1! + 4! + 5! = 1 + 24 + 120 = 145 (Strong number) 123 = 1! + 2! + ...

Read More
Showing 9391–9400 of 25,466 articles
« Prev 1 938 939 940 941 942 2547 Next »
Advertisements