Program to count the number of characters in a given string using while loop. Useful for calculating the length of a given string as C doesn’t have an inbuilt function for the same.
Logic behind the program is to check till half of the number (n/2) because it has been observed that the remainders get repeated after half of the number. Therefore, checking for remainders till n/2 is sufficient enough. The use of modulus operator(%) is important in this regard.
A String can be checked for palindrome using two while loops. One for counting the string length and second for checking the [i]th element of the substring with the original string to be compared with.
Sum of Digits of a number is taken out in two steps. One, using the modulus operator (%) and taking remainder by dividing by 10 to get individual digits and then diving the number itself by 10 to reduce the least significant. It is similar to reversing digits of the number.
Reverse of Digits of a number is taken out in two steps. One, using the modulus operator (%) and taking remainder by dividing by 10 to get individual digits and then diving the number itself by 10 to reduce the least significant. It is similar to taking sum of digits.
Selection sort is a sorting algorithm, specifically an in-place comparison sort. Selection sort is noted for its simplicity, and also has performance advantages over more complicated algorithms in certain situations.
Transpose of a Matrix is one of the operations performed on Matrices wherein the transpose of a matrix A is a matrix formed from A by interchanging the rows and columns such that row i of matrix A becomes column i of the transposed matrix.
Sum of two Matrices is one of the operations performed on Matrices wherein Matrix A and Matrix B are are summed together resulting in a Matrix C which is the new Matrix formed by addition of A & B.
Sum of Diagonals of a Matrix is one of the operations performed on Matrices wherein the individual elements on the Diagonal of the Matrix are summed together.
The malloc function is one of the functions in standard C to allocate memory. Upon successful allocation, malloc returns a void pointer (void *), which indicates that it is a pointer to a region of unknown data type. Here, we’ll use malloc() to dynamically assign memory from the HEAP to an array at runtime. Language [...]