Found 1339 Articles for C

C program to remove the brackets from a given input.

Bhanu Priya
Updated on 26-Mar-2021 07:18:28

852 Views

ProblemLet’s create a simplified expression by removing brackets from the expressions.SolutionExample 1Input: A string expression with bracket is as follows: (x+y)+(z+q) The output is as follows: x+y+z+qExample 2The input is as follows: (x-y+z)-p+q The output is as follows: x-y+z-p+qAlgorithmRefer an algorithm to remove the brackets from a given input.Step 1: Declare and read the input at runtime.Step 2: Traverse the string.Step 3: Copy each element of the input string into new string.Step 4: If anyone parenthesis is encountered as an element, replace it with empty space.ExampleFollowing is the C program to remove the brackets from a given input −#include int ... Read More

C program to search an array element using Pointers.

Bhanu Priya
Updated on 26-Mar-2021 07:14:58

15K+ Views

ProblemWrite a C program to search an element from an array at runtime by the user and the result to be displayed on the screen after search. If the searching element is not in an array then, we need to search element is not found.SolutionAn array is used to hold the group of common elements under one nameThe array operations are as follows −InsertDeleteSearchAlgorithmRefer an algorithm to search the elements into an array with the help of pointers −Step 1 − Declare and read the number of elements.Step 2 − Declare and read the array size at runtime.Step 3 − ... Read More

Explain unformatted input and output functions in C language

Sindhura Repala
Updated on 21-Jan-2025 15:58:29

8K+ Views

Unformatted input and output functions read a single input sent by the user and permit the display of the value as the output at the console. Unformatted input functions The unformatted input functions in the C programming language are used only for character data type or character string/array and cannot be used for any other datatype. These functions are used to read a single input from the user and this allows the user to display the value at the console. The getchar() Function This getchar() function reads only the first single character from the given keyboard that multiplies characters is typed ... Read More

Find the largest number in a series by using pointers in C language

Sindhura Repala
Updated on 20-Jan-2025 17:21:54

4K+ Views

A pointer is a variable that stores the address of another variable. We can hold the null values by using pointer. It can be accessed by using pass by reference. Also, there is no need of initialization, while declaring the variable. Instead of holding a value directly, it holds the address where the value is stored in memory. The two main operators used with pointers are the dereferencing operator and the address operator. These operators are used to declare pointer variables and access the values stored at those address. Pointer variable uses the dereferencing operator to access the value it ... Read More

C program to sort an array by using merge sort

Bhanu Priya
Updated on 26-Mar-2021 07:16:54

3K+ Views

An array is a group of related data items which share’s a common name. A particular value in an array is identified with the help of its "index number".Declaring arrayThe syntax for declaring an array is as follows −datatype array_name [size];For example, float marks [50]It declares ‘marks’ to be an array containing 50 float elements.int number[10]It declares the ‘number’ as an array to contain a maximum of 10 integer constants.Each element is identified by using an "array index".Accessing array elements is easy by using the array index.The logic we use for merge sort is as follows −void MergeSort(int *array, int ... Read More

C program to delete an array element using Pointers

Bhanu Priya
Updated on 26-Mar-2021 07:12:36

4K+ Views

ProblemWrite a C program to delete an element from an array at runtime by the user and the result to be displayed on the screen after deletion. If the deleted element is not in an array, then we need to display Invalid Input.SolutionAn array is used to hold the group of common elements under one name.The array operations are as follows −InsertDeleteSearchAlgorithmRefer an algorithm to delete the elements into an array with the help of pointers.Step 1 − Declare and read the number of elements.Step 2 − Declare and read the array size at runtime.Step 3 − Input the array ... Read More

C Program to insert an array element using pointers.

Bhanu Priya
Updated on 26-Mar-2021 07:10:20

6K+ Views

ProblemWrite a C program to insert the elements into an array at runtime by the user and the result to be displayed on the screen after insertion. If the inserted element is greater than the size of an array, then, we need to display Invalid Input.SolutionAn array is used to hold the group of common elements under one name.The array operations are as follows −InsertDeleteSearchAlgorithmRefer an algorithm to insert the elements into an array with the help of pointers.Step 1: Declare and read the number of elements.Step 2: Declare and read the array size at runtime.Step 3: Input the array ... Read More

C program to sort an array in an ascending order

Bhanu Priya
Updated on 10-Dec-2024 13:01:40

120K+ Views

Problem Sort the given array in descending or ascending order based on the code that has been written. Solution An array is a group of related data items which share’s a common name. A particular value in an array is identified with the help of its "index number". Declaring array The syntax for declaring an array is as follows − datatype array_name [size]; For example, float marks [50] It declares ‘marks’ to be an array containing 50 float elements. int number[10] It declares the ‘number’ as an array to contain a maximum of 10 integer constants. Each element is identified ... Read More

C program to sort an array in descending order

Bhanu Priya
Updated on 26-Mar-2021 07:08:57

17K+ Views

ProblemSort the given array in descending or ascending order based on the code that has been written.SolutionAn array is a group of related data items which share’s a common name. A particular value in an array is identified with the help of its "index number".Declaring arrayThe syntax for declaring an array is as follows −datatype array_name [size];For example, float marks [50]It declares ‘marks’ to be an array containing 50 float elements.int number[10]It declares the ‘number’ as an array to contain a maximum of 10 integer constants.Each element is identified by using an "array index".Accessing array elements is easy by using ... Read More

How to calculate sum of array elements using pointers in C language?

Sindhura Repala
Updated on 20-Jan-2025 17:20:43

20K+ Views

Pointers A pointer is a variable that stores the address of another variable. Instead of holding a value directly, it holds the address where the value is stored in memory. The two main operators used with pointers are the dereferencing operator and the address operator. These operators are used to declare pointer variables and access the values stored at those addresses. The pointer variable uses the dereferencing operator to access the value it points to. We use the address operator to obtain the memory address of a variable and store it in the pointer variable. We use pointers to access ... Read More

Advertisements