Bhanu Priya

Bhanu Priya

1,061 Articles Published

Articles by Bhanu Priya

Page 40 of 107

C program to find in which quadrant the coordinates lie.

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

In C programming, determining which quadrant coordinates lie in is a fundamental problem in coordinate geometry. A coordinate system is divided into four quadrants based on the signs of the x and y coordinates. Syntax if (x > 0 && y > 0) // First quadrant else if (x < 0 && y > 0) // Second quadrant else if (x < 0 && y < 0) // Third quadrant else if (x > 0 && y < 0) // Fourth ...

Read More

C program to remove the brackets from a given input.

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

In C programming, removing brackets from mathematical expressions is a common string manipulation task. This involves processing the expression to eliminate parentheses while maintaining the correct mathematical meaning, especially handling sign changes when brackets are preceded by a minus sign. Syntax char* removeBrackets(char expression[]); Algorithm The algorithm to remove brackets follows these steps − Step 1: Read the input expression string Step 2: Traverse each character in the string Step 3: Copy non-bracket characters to result string Step 4: When encountering '(' preceded by '-', flip signs inside brackets Step 5: Skip ...

Read More

C program to search an array element using Pointers.

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

In this tutorial, we'll learn how to search for an element in an array using pointers in C. This approach demonstrates the power of pointer arithmetic and dynamic memory management for array operations. Syntax int search(int *array, int size, int element); // Returns: index if found, -1 if not found Algorithm Here's the step-by-step algorithm to search elements in an array using pointers − Step 1 − Declare and read the array size Step 2 − Input array elements Step 3 − Declare a pointer to traverse the array Step 4 − ...

Read More

C program to sort an array by using merge sort

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

Merge sort is a divide-and-conquer algorithm that recursively divides an array into two halves, sorts each half separately, and then merges the sorted halves back together. It guarantees O(n log n) time complexity in all cases. Syntax void MergeSort(int array[], int left, int right); void Merge(int array[], int left, int middle, int right); How Merge Sort Works The merge sort algorithm follows these steps − Divide: Split the array into two halves at the middle point Conquer: Recursively sort both halves Combine: Merge the two sorted halves into a single sorted array ...

Read More

C program to delete an array element using Pointers

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

In C, deleting an element from an array involves shifting all subsequent elements one position to the left. This operation can be efficiently implemented using pointers to manipulate array elements directly through memory addresses. Syntax void deleteElement(int *array, int size, int position); // array: pointer to the array // size: current size of the array // position: 1-based position of element to delete Algorithm The algorithm to delete an element from an array using pointers − Declare and read the array size Allocate memory dynamically using malloc() Input array elements Read the ...

Read More

C Program to insert an array element using pointers.

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

In C programming, inserting elements into an array using pointers involves dynamically allocating memory and manipulating array elements through pointer arithmetic. This technique is useful when you need to add elements at specific positions during runtime. Syntax void insertElement(int *array, int size, int position, int element); int *ptr = (int*)malloc(size * sizeof(int)); Algorithm The algorithm to insert elements into an array using pointers − Declare and read the array size Allocate memory dynamically using malloc() Input array elements using pointer notation Read the insertion position and new element Validate position (must be ...

Read More

C program to sort an array in an ascending order

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

In C programming, sorting an array in ascending order means arranging elements from smallest to largest value. This is a fundamental operation that can be implemented using various algorithms, with bubble sort being one of the most commonly taught approaches. Syntax // Basic bubble sort algorithm for (i = 0; i < n; i++) { for (j = i + 1; j < n; j++) { if (arr[i] > arr[j]) { // Swap ...

Read More

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
Showing 391–400 of 1,061 articles
« Prev 1 38 39 40 41 42 107 Next »
Advertisements