Programming Articles

Page 929 of 2547

C program to sort an array in descending order

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

Sorting an array in descending order means arranging elements from highest to lowest value. This is commonly achieved using various sorting algorithms, with bubble sort being one of the simplest approaches. Syntax // Bubble sort for descending order for (i = 0; i < n; i++) { for (j = i + 1; j < n; j++) { if (arr[i] < arr[j]) { // Swap elements ...

Read More

C program to find the unique elements in an array.

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

In C programming, finding unique elements in an array means identifying elements that appear exactly once. This is a common array manipulation problem that can be solved using nested loops to compare each element with all other elements. Syntax for(int i = 0; i < n; i++) { for(int j = 0; j < n; j++) { if(array[i] == array[j] && i != j) break; } ...

Read More

C program for a number to be expressed as a sum of two prime numbers.

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

In C, we can check if a given positive integer can be expressed as the sum of two prime numbers. This concept is related to Goldbach's conjecture, which states that every even integer greater than 2 can be expressed as the sum of two primes. Syntax int isPrime(int n); // Returns 1 if n is prime, 0 otherwise Algorithm The algorithm to check if a number can be expressed as sum of two primes is − Step 1: Input the number to be checked Step 2: Iterate from i = 2 to ...

Read More

C program to find the solution of linear equation

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

We can apply the software development method to solve the linear equation of one variable in C programming language. A linear equation of the form ax + b = 0 can be solved by rearranging to find x = -b/a (provided a ≠ 0). Syntax float solve(float a, float b); x = -b / a; // where a != 0 Requirements The equation should be in the form of ax + b = 0 a and b are inputs, we need to find the value of x Handle the case where a ...

Read More

C program to replace all zeros with one in a given integer.

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

In C programming, replacing all zeros with ones in an integer requires digit-by-digit processing. This can be achieved using recursion or iterative approaches to extract, modify, and reconstruct the number. Syntax int replaceZeros(long int number); Algorithm Follow these steps to replace all zeros with ones in an integer − Step 1 − Input the integer from the user Step 2 − Traverse the integer digit by digit Step 3 − If a zero is encountered, replace it with one Step 4 − Reconstruct and return the modified number Method 1: ...

Read More

C program to compare the structure variables

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

In C programming language, a structure is a collection of different datatype variables, which are grouped together under a single name. While C doesn't provide a built-in operator to compare entire structures directly, we can compare structure variables by comparing their individual members. Syntax struct tagname { datatype member1; datatype member2; datatype membern; }; Structure Declaration and Initialization The general form of a structure declaration is as follows − struct tagname { datatype member1; ...

Read More

Explain queue by using linked list in C language

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

A queue is a linear data structure that follows the First In First Out (FIFO) principle. When implemented using linked lists, we can avoid queue overflow and underflow issues that occur with array-based implementations. The linked list provides dynamic memory allocation, allowing the queue to grow or shrink as needed. Operations carried out on a queue using linked lists in C programming language are as follows − Enqueue − Insert an element at the rear Dequeue − Remove an element from the front Display − Show all elements in the queue Front − Get the front element ...

Read More

Explain the stack by using linked list in C language

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

A stack is a linear data structure that follows the Last-In-First-Out (LIFO) principle. When implementing a stack using a linked list in C, we can avoid stack overflow and underflow issues by dynamically allocating memory. This approach provides flexibility in memory usage and can grow or shrink based on requirements. Syntax struct node { int data; struct node *next; } *top; void push(int value); void pop(); int peek(); int isEmpty(); Stack Operations The primary operations performed on a stack using linked list are − ...

Read More

Explain the deletion of element in linked list

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

Linked lists use dynamic memory allocation which allows them to grow and shrink during runtime. A linked list is a collection of nodes where each node contains two parts: data (stores the value) and link (points to the next node). Data Link Data Link Data Link NULL ...

Read More

C program to calculate the standard deviation

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

Standard deviation is used to measure deviation of data from its mean. The mathematical formula to calculate the standard deviation is as follows − $$s=\sqrt{Variance}$$ where Variance$$=\frac{1}{n}\:\:\displaystyle\sum\limits_{i=1}^n (x_{i}-m)^{2}$$ and $$m=mean=\frac{1}{n}\:\displaystyle\sum\limits_{i=1}^n x_{i}$$ Syntax #include double sqrt(double x); Algorithm Refer an algorithm given below to calculate the standard deviation for the given numbers − Step 1 − Read n items. Step 2 − Calculate sum and mean of the items. Step 3 − Calculate variance. Step 4 − Calculate standard deviation. The logic used in the ...

Read More
Showing 9281–9290 of 25,466 articles
« Prev 1 927 928 929 930 931 2547 Next »
Advertisements