Solution: We use calloc() function to allocate memory dynamically to arrays in C programming. We scan the elements into array using “data+i” expression into consecutive memory locations. We consider the first element as largest element …
Solution: Passing references(addresses) as parameters to function is called “Call By Reference”. We need to specify the pointer type arguments in the called function to collect these references. We can access the information(a, b) of …
Solution: We read the input values into variables n1, n2 using pointer variables p1 and p2. We add the values of n1 and n2 through pointers.
Solution: Address operator is used to returns the memory location of specified variable. Pointer operator is used to returns the data which is present in the specified memory location. The following example describes the use …
Solution: Pointers are powerful features in C programming. Addressing is important before start of Pointers in C. Address in C If you have a variable called ‘x’ in yprogram then &x will give you its …
Solution: We can allocate memory in 2 ways in C programming. malloc() function is used to allocate memory dynamically. Stdlib.h header file is providing pre-defined functionality to allocate and de-allocate the memory dynamically. In this …
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 …
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: 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: 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 …