C Lab programs Archive
1 + 1/2 + 1/3 + 1/4 + 1/5 … 1/n terms.
Solution: A positive integer is called an Armstrong number (of order n) if xyz… = x^n + y^n + z^n In the case of an Armstrong number of 3 digits, the sum of cubes of …
Solution: Array is a collection of similar type of elements. Array allowed storing duplicate values also. In this code, we display only elements which are uniquely present in the array. We use nested loop to …
Solution: In this approach, we take two arrays to store even and odd numbers after separation. We repeat the loop from start index to end index and check the element is even or not. We …
Solution: In this code, we use bubble sort algorithm to sort the elements in array. We assume list is an array of n elements. We further assume that swap function swaps the values of the …
Solution: In this approach, we read the size of matrix using m and n variables. We use the same dimension to read both matrix elements. After perform multiplication, we store the results into third matrix. …
Solution: In this code, we search for an element in the given matrix. We define the array with elements directly. We use nested loops to search for element using row and column index. When element …
Solution: We use fgets() function to read the string from the console. stdin is the pre-defined object that represents keyboard standard input. strlen() function is used to find the length of input string. Using an …
Solution: string.h header file is providing pre-defined function to compare 2 strings. Pre-defined strcmp() function returns 0 if both strings are equal else it returns the ASCII difference between mismatching characters. Using the custom defined …
Solution: The strcpy() function is a built-in library function, declared in the string.h header file. It copies the source string to the destination string until a null character (\0) is reached. In this program, we …