Found 1401 Articles for C

C program to search an array element using Pointers.

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

13K+ 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

Bhanu Priya
Updated on 20-Jun-2024 01:22:07

6K+ Views

Unformatted input and output functions read a single input sent by the user and permits to display the value as the output at the console. Unformatted input functions The unformatted input functions in C programming language are explained below − getchar() It reads a character from the keyboard. The syntax of getchar() function is as follows − Variablename=getchar(); For example, Char a; a = getchar(); Example Program Following is the C program for getchar() function −  Live Demo #include int main(){    char ch;    FILE *fp;    fp=fopen("file.txt", "w"); //open the file in write mode    printf("enter the text ... Read More

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

Bhanu Priya
Updated on 20-Jun-2024 01:31:22

3K+ Views

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. The syntax for pointer is as follows − pointer variable= & another variable; For example, p =&a; Algorithm Refer an algorithm given below for finding the largest number in a series with the help of pointers. Step 1: Start Step 2: Declare integer variables Step 3: Declare pointer variables Step 4: Read 3 numbers from console Step 5: Assign ... Read More

C program to sort an array by using merge sort

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

2K+ 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

5K+ 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 02-Sep-2023 10:21:10

89K+ 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

C program to sort an array in descending order

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

14K+ 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?

Bhanu Priya
Updated on 20-Jun-2024 01:36:52

17K+ Views

Pointer is a variable which stores the address of other variable.Consider the following statement −int qty = 179;Declaring a pointerThe syntax for declaring a pointer is as follows −int *p;Here, ‘p’ is a pointer variable which holds the address of other variable.Initialization of a pointerAddress operator (&) is used to initialize a pointer variable.For example, int qty = 175; int *p; p= &qty;Array of PointersIt is collection of addresses (or) collection of pointers.DeclarationFollowing is the declaration for array of pointers −datatype *pointername [size];For example, int *p[5];It represents an array of pointers that can hold five integer element addresses.Initialization‘&’ is used ... Read More

C program to find the unique elements in an array.

Bhanu Priya
Updated on 14-Sep-2023 02:28:29

28K+ Views

ProblemFind the non-repeating element in an array by using the two loops. One is for the current element and the other is to check, if an element is already present in an array or not.SolutionConsider an example given below −15, 15, 16, 15, 13, 15Here, the non-repeated elements in an array are 16 and 13.AlgorithmRefer an algorithm given below for finding the unique or the non-repeated elements in an array.Step 1 − Declare an array and input the array elements at run time.Step 2 − Start traversing the array and check, if the current element is already present in an ... Read More

Advertisements