C Interview Questions and Answers

What are the usage of pointer in C?

A pointer is used in the following cases 
Accessing array elements
Dynamic memory allocation
Call by Reference
Data Structures like tree, graph, linked list etc.

What is Null Pointers?

A pointer is said to be a null pointer when its right value is either null or 0. Remember, a null pointernever point to valid data.

What is a pointer on pointer?

Pointer variable can hold the address of another pointer variable is known as a pointer on pointer.

What is the advantage of declaring void pointers?

The void pointer can be converted anytime into any generic type pointer by casting operator.

What is a pointer to a function?

A pointer can hold the reference of the function is called pointer to a function.

What is the difference between actual and formal parameters?

The parameters sent to the function at calling end are called as actual parameters while at the receiving of the function definition called as formal parameters.

What is Pass by Value & Pass by Reference?

Pass by Value:In this method,the value of each of the actual arguments in the calling function is copied into corresponding formal arguments of the called function.In pass by value,the changes made to formal arguments in the called function have no effect on the values of actual arguments in the calling function.

Pass by Reference:In this method,the addresses of actual arguments in the calling function are copied into formal arguments of the called function. This means that using these addresses, we would have an access to the actual arguments and hence we would be able to manipulate them.

What Is an Array?

An array is a collection of variables with same data type. Item of array is called an element. All elements in an array are referenced by the name of the array and are stored in a set of consecutive, adjacent memory slots.the index of an array starts from 0.

How do declare an array?

We can declare an array by specify its data type, name and the number of elements the array holds between square brackets immediately following the array name.

ex
int array_int[10]; 

Can we access array using pointer in C language?

Yes, by holding the base address of array into pointer, we can access the array using pointer.

What is a string? How do you know its length?

In C, a string is a character array which is terminated by a null character (‘’). The null character tells the string functions to end of the string.
The strlen() function can be used to measure the length of a string. It returns the total number of bytes taken by the string and it is not counted the null character in the string.

What is static memory allocation?

Allocated the memory at compile time called static memory allocation.It is fixed and can't be increased at runtime.

Latest Updates

Ratio and Proportion

A certain sum of money is divided between A and B in the ratio of 5/4 : 5/3 and A got Rs. 360/-. Find the total sum of money and B’s share?

In an office, the ratio of the salaries of an officer and a clerk is 15:7. If the salary of a clerk is Rs. 720/- less than the salary of the officer, find the salary of each?

In an election to a municipal council, the votes secured by two candidates are in the ratio 13:19. The elected candidates gets 312 votes more than the second candidate. How many votes are secured by the second candidate?

A certain sum of money is divided between Murthy and Prasad in the ratio 22/7 : 8/3. If Murthy gets Rs. 120/- more than Prasad, find the share of each?

In a cricket test series, the runs made by Raju and Tendulkar are in the ratio 5:9 and Tendulkar and Azar are in the ratio 6:7. What are the runs made by them if Azar makes 187 runs more than Raju?

If A:B = 2:3 and B:C = 9:5 find A:B:C?

If A:B = 3/5:5/7 and B:C = 3/4:2/5, find A:B:C?

If R:S = 0.01:0.11 and S:T = 2.2:1, Find R:S:T?

In a school, Under a Saving Scheme, Rekha saves 3/2 times the savings of Bindu, Geeta saves 4 times the savings of Rekha. Find the ratio of the savings of all the three in least terms?

Simplification

A man left 1/3 rd of his property to his wife and 3/5 th of the remainder to his daughter. He gave the rest to his son who received Rs. 6400/-. How much was his original property worth?

Ratio and Proportion

In a school 4/9 of the pupils are boys. There are 125 girls. How many boys are there?

If A:B = 3:4 and B:C = 5:6, find A:C?

IF X:Y = 3:4 AND Y:Z = 4:5, FIND X:Y:Z?

Area

A house site is in the shape of a square. Its area is 1225 sq metres. What is its perimeter?

The area of a square field is 7396 sq metres. Find its perimeter?

Numbers

Twice the first of three consecutive even integer is 6 more than the second integer. What is the third integers?

Ratio and Proportion

If 2x=3y and 4y=5z, then what is x:z=?

What quantity must be added to each term of the ratio a + b : a – b to make it equal to (a + b)2 : (a – b)2 ?