Found 1452 Articles for C

C program to store the car information using dynamic linked list.

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

3K+ Views

Linked lists use dynamic memory allocation i.e. they grow and shrink accordingly. It is collection of nodes.Node has two parts which are as follows −DataLinkTypes of Linked ListsThe types of linked lists in C programming language are as follows −Single / Singly linked listsDouble / Doubly linked listsCircular single linked listCircular double linked listAlgorithmRefer an algorithm given below for storing the car information by using the dynamic linked list.Step 1 − Declare structure variables.Step 2 − Declare Function definition to display.Step 3 − Allocate dynamic memory allocation to variable.Step 4 − Use do while loop to enter the car information.Step ... Read More

C program to find the area of circle and cylinder using structures.

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

1K+ Views

In C programming language, we can find the area of circle, area and volume of cylinder with the help of structures.The logic used to find area of circle is as follows −s.areacircle = (float)pi*s.radius*s.radius;The logic used to find area of cylinder is as follows −s.areacylinder = (float)2*pi*s.radius*s.line + 2 * s.areacircle;The logic used to find the volume of cylinder is −s.volumecylinder = s.areacircle*s.line;AlgorithmRefer an algorithm given below to find the area of circle and cylinder along with other parameters by using structures.Step 1 − Declare structure members.Step 2 − Declare and initialize the input variables.Step 3 − Enter length and ... Read More

What is an anagram in C language?

Bhanu Priya
Updated on 26-Mar-2021 07:52:46

3K+ Views

Anagram strings are nothing but, all the characters that occur for the same number of times in another string, which we call as anagrams.A user enters two strings. We need to count how many times each letter ('a' to 'z') appears in them and then, compare their corresponding counts. The frequency of an alphabet in a string is how many times it appears in it.If two strings have same count of the frequency of particular alphabet then, we can say those two strings are anagrams.Example 1String 1 − abcdString 2 − bdacThese two strings have same letters which appear once. ... Read More

C Program find nCr and nPr.

Bhanu Priya
Updated on 26-Mar-2021 07:50:25

14K+ Views

In C programming language, nCr is referred as the combination. nCr is the selection of r objects from a set of n objects, where the order of objects does not matter.nPr is referred as the permutation. nPr is arrangement of 'r' objects from a set of 'n' objects, which should be in an order or sequence.Permutations and combinations formulasThe formulas to find the permutation and combination of given numbers in C language are given below −nCr = n!/(r!*(n-r)!)nPr = n!/(n-r)!.The logic used to find nCr is as follows −result = factorial(n)/(factorial(r)*factorial(n-r));The logic used to find nPr is as follows −result ... Read More

C program to perform intersection operation on two arrays

Bhanu Priya
Updated on 26-Mar-2021 07:55:31

6K+ Views

Intersection operationIf array 1 = { 1,2,3,4,6}  Array 2 = {1,2,5,6,7}Then, intersection of array1 and array 2 isArray1 ^ array 2 = {1,2,3,4,6} ^ {1,2,5,6,7}         = {1,2,6}Set of common elements is called an intersection.The logic for intersection is as follows −k=0; for(i=0;i

C program to perform union operation on two arrays

Bhanu Priya
Updated on 26-Mar-2021 07:52:41

11K+ Views

A union is a special data type available in C programming language that allows to store different data types in the same memory location. Unions provide an efficient way of using the same memory location for multiple-purpose.Union operationIf array 1 = { 1,2,3,4,6}    Array 2 = {1,2,5,6,7}Then, union of array1 and array 2 isArray1 U array 2 = {1,2,3,4,6} U {1,2,5,6,7}                              = {1,2,3,4,5,6,7}Set of all elements without repetition is called union.The logic for union is as follows −for(i=0;i

C program to sort names in alphabetical order

Bhanu Priya
Updated on 26-Mar-2021 07:48:29

54K+ Views

User has to enter number of names, and those names are required to be sorted in alphabetical order with the help of strcpy() function.An array of characters (or) collection of characters is called a string.DeclarationFollowing is the declaration for an array −char stringname [size];For example, char string[50]; string of length 50 characters.InitializationUsing single character constantchar string[10] = { ‘H’, ‘e’, ‘l’, ‘l’, ‘o’ ,‘\0’}Using string constantschar string[10] = "Hello":;AccessingThere is a control string "%s" used for accessing the string till it encounters ‘\0’strcpy ( )This function is used for copying source string into destination string.The length of the destination string ... Read More

What is a simple assertion in C language?

Bhanu Priya
Updated on 26-Mar-2021 07:47:41

202 Views

An assertion is a statement which is used to declare positively that a fact must be true when that line of code is reached.Assertions are useful for obtaining the expected conditions which are met.Simple AssertionSimple assertion can be implemented by using assert (expression) method, which is present in assert.h header file.The syntax for simple assertion is as follows −assert(expression)In simple assertion, When the condition passed to an assertion which is a true, then, there is no action.The behaviour on false statements depends completely on compiler flags.When assertions are enabled, a false input causes a program to halt.When assertions are disabled, ... Read More

C Program to find sum of perfect square elements in an array using pointers.

Bhanu Priya
Updated on 26-Mar-2021 07:45:42

1K+ Views

ProblemWrite a program to find the sum of perfect square elements in an array by using pointers.Given a number of elements in array as input and the sum of all the perfect square of those elements present in the array is output.SolutionFor example, Input= 1, 2, 3, 4, 5, 9, 10, 11, 16 The perfect squares are 1, 4, 9, 16. Sum = 1 + 4 + 9 +16 = 30 Output: 30AlgorithmRefer an algorithm given below to find the sum of perfect square elements in an array by using pointers. Step 1 − Read number of elements in array at ... Read More

C program to add all perfect square elements in an array.

Bhanu Priya
Updated on 26-Mar-2021 07:42:51

2K+ Views

ProblemWrite a program to find the sum of perfect square elements in an array.Given a number of elements in array as input and the sum of all the perfect square of those elements present in the array is output.SolutionFor example, Input= 1, 2, 3, 4, 5, 9, 10, 11, 16 The perfect squares are 1, 4, 9, 16. Sum = 1 + 4 + 9 +16 = 30 Output: 30AlgorithmRefer an algorithm given below to add the perfect square elements in an array.Step 1 − Read number of elements in array at runtime.Step 2 − Input the elements.Step 3 − ... Read More

Advertisements