Programming Articles

Page 924 of 2547

Differentiate between int main and int main(void) function in C

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

In C programming, there is a subtle but important difference between int main() and int main(void). Both declare the main function to return an integer, but they differ in how they handle function parameters. Syntax int main() { // Function body return 0; } int main(void) { // Function body return 0; } The int main() Function The int main() function with empty parentheses indicates that the function can accept any number of arguments. In C, when ...

Read More

What are string searching functions in C language?

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

String searching functions in C are built-in library functions that help locate specific characters, substrings, or patterns within strings. These functions are part of the standard C library (string.h) and provide efficient ways to search and analyze string content. Syntax #include char *strchr(const char *str, int c); char *strrchr(const char *str, int c); char *strpbrk(const char *s1, const char *s2); size_t strspn(const char *s1, const char *s2); size_t strcspn(const char *s1, const char *s2); char *strtok(char *s1, const char *s2); char *strtok_r(char *s1, const char *s2, char **saveptr); String Searching Functions Overview ...

Read More

What are memory operations in C language?

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

Memory operations in C are functions that manipulate raw bytes in memory, regardless of data type. These functions are declared in #include and work with void* pointers to handle any data type. Syntax The five primary memory functions have the following prototypes − void *memchr(const void *s, int c, size_t n); int memcmp(const void *s1, const void *s2, size_t n); void *memcpy(void *dest, const void *src, size_t n); void *memmove(void *dest, const void *src, size_t n); void *memset(void *s, int c, size_t n); Memory Functions Overview ...

Read More

C program to store inventory system using structures

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

In C programming, an inventory management system can be efficiently implemented using structures to store and organize product information. Structures allow us to group related data of different types under a single entity, making it perfect for managing inventory details like item names, codes, quantities, prices, and manufacturing dates. Syntax struct structure_name { datatype member1; datatype member2; /* more members */ }; Features of Structures The key features of structures in C programming are − Enables grouping of different data ...

Read More

C program to sort names in alphabetical order using structures

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

Structure is a collection of different datatype variables, grouped together under a single name. In this article, we will learn how to sort names in alphabetical order using structures in C. Syntax struct structure_name { datatype member1; datatype member2; // ... more members }; Features of Structure The features of structure in the C programming language are as follows − It is possible to copy the contents of all the structure elements of different datatypes to another structure variable of ...

Read More

C program to compare if the two matrices are equal or not

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

In C programming, comparing two matrices for equality involves checking both their dimensions and corresponding elements. Two matrices are considered equal if they have the same dimensions (rows and columns) and all corresponding elements are identical. Syntax // Matrix comparison logic if (rows1 == rows2 && cols1 == cols2) { // Compare each element for (int i = 0; i < rows1; i++) { for (int j = 0; j < cols1; j++) { ...

Read More

C program to sort all columns and rows of matrix

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

In C programming, sorting matrix rows and columns involves rearranging elements within each row in ascending order and elements within each column in descending order. This operation requires nested loops to traverse and compare matrix elements. Syntax /* Row sorting (ascending) */ for (i = 0; i < rows; i++) { for (j = 0; j < cols; j++) { for (k = j + 1; k < cols; k++) { if (matrix[i][j] ...

Read More

C program to interchange the diagonal elements in given matrix

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

In C programming, interchanging the diagonal elements of a matrix involves swapping the main diagonal elements with the secondary (anti) diagonal elements. This operation is only possible with square matrices where the number of rows equals the number of columns. Syntax /* Logic to interchange diagonal elements */ for (i = 0; i < n; i++) { temp = matrix[i][i]; /* Store main diagonal element */ matrix[i][i] = matrix[i][n-i-1]; /* Assign ...

Read More

C program to perform operations on two halves' in a single array

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

In C programming, we can perform different operations on two halves of a single array. This approach is useful when you need to apply distinct sorting criteria to different portions of your data. Let's explore how to split an array into two halves and sort the first half in ascending order while sorting the second half in descending order. Syntax // Splitting array into two halves int mid = n / 2; // where n is array size // Bubble sort for ascending order (first half) for (i = 0; i < mid; i++) { ...

Read More

C program to generate the value of x power n using recursive function

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

In C programming, calculating xn (x raised to the power n) can be efficiently done using recursive functions. This approach breaks down the problem into smaller subproblems, making the solution elegant and mathematically intuitive. Syntax long int power(int x, int n); Algorithm The recursive algorithm uses the following mathematical properties − If n = 1, then xn = x (base case) If n is even, then xn = (xn/2)2 If n is odd, then xn = x × xn-1 Example: Recursive Power Function Here's a complete C program that ...

Read More
Showing 9231–9240 of 25,466 articles
« Prev 1 922 923 924 925 926 2547 Next »
Advertisements