An array of characters is called a string.DeclarationFollowing is the declaration for an array −char stringname [size];For example − char a[50]; string of length 50 charactersInitializationUsing single character constant −char a[10] = { ‘H’, ‘e’, ‘l’, ‘l’, ‘o’ ,‘\0’}Using string constants −char a[10] = “Hello”:;AccessingThere is a control string “%s” ... Read More
A strong number is a number, where the sum of the factorial of the digits is equal to the number itself.Example123 != 1!+2!+3! = 1 + 2 + 6 = 9Here, 123 is not a strong number because, the sum of factorial of digits is not equal to the ... Read More
The two’s complement for a given binary number can be calculated in two methods, which are as follows −Method 1 − Convert the given binary number into one’s complement and then, add 1.Method 2 − The trailing zero’s after the first bit set from the Least Significant Bit (LSB) including ... Read More
These are used by the programmers to create their own data types and define what values the variables of these datatypes can hold.The keyword is enum.SyntaxThe syntax for enumerated data type is as follows −enum tagname{ identifier1, identifier2, ……., identifier n };ExampleGiven below is an example for enumerated data ... Read More
Try to delete the same numbers present in an array. The resultant array consists of unique elements.The logic to delete the duplicate elements in an array is as follows −for(i = 0;i<number;i++){ for(j = i+1; j < number; j++){ if(a[i] == a[j]){ ... Read More
Take two arrays as input and try to merge or concatenate two arrays and store the result in third array.The logic to merge two arrays is given below −J = 0, k = 0 for(i = 0;i<o;i++){ // merging two arrays if(a[j]<=b[k]){ c[i] = a[j]; ... Read More
In a given matrix, when most of the elements are zero then, we call it as sparse matrix. Example − 3 x3 matrix1 1 0 0 0 2 0 0 0In this matrix, most of the elements are zero, so it is sparse matrix.ProblemCheck whether a matrix is a sparse ... Read More
To begin with, let us understand what are trailing zeros in a binary number.Trailing zerosThe position of zeros after first one from the least significant bit (LSB) is called as trailing zeros in binary number.Example104 is decimal numberBinary number of 104 is: (MSB) 1101000(LSB)Here, MSB refers to Most Significant Bit.LSB ... Read More
Consider the factors given below to write a C program to rotate the bits for a given number.Rotating the bit from left to right or right to left.In left rotation, the bits are shifted from left to right.In right rotation, the bits are shifted from right to left.Take a number ... Read More
Triangle consists of three sides and three angles. Based on the three sides, there are three types of triangle −Equilateral triangle: All three sides are equal.Isosceles triangle: All two sides are equal.Scalene triangle: No sides are equal.Follow the algorithm given below for writing the respective program.AlgorithmStep 1: Declare three sides ... Read More