C programming – most frequently asked questions

c programming


In most of the colleges C is taught as the primary language. For data structure course also C programming language is used. Although some institutes teach Java or python as well but C programming language is evergreen. Here we have listed few questions which are asked frequently in technical written exam and in interview as well.
We suggest that don’t just read these question and answers, but also practice on paper and then compile them.

Theoretical Questions:

Q: What is the difference between C and C++ ?

A: The major difference between C and C++ is that C is a procedural programming language and does not support classes and objects, while C++ is an object oriented programming language.

Q: What is a dangling pointer?

A: pointer pointing to non-existing memory location is called dangling pointer.

Q:  What is the difference between while and do-while loop?

The do while loop executes the content of the loop once before checking the condition of the while. Whereas a while loop will check the condition first before executing the content.

Q: What are different storage class specifiers in C?

A: i)auto
ii)register
iii)static
iv)extern

Q: What is recursion?

A: A programming technique in which a function may call itself. The process of calling a function by itself is known as recursion.

Q: What is the difference between array and linked list?

A: The difference between arrays and linked lists are:
– Arrays are linear data structures. Linked lists are linear and non-linear data structures.
– Linked lists are linear for accessing, and non-linear for storing in memory
– Array has homogeneous values. And each element is independent of each other positions. Each node in the linked list is connected with its previous node which is a pointer to the node.
– Array elements can be modified easily by identifying the index value. It is a complex process for modifying the node in a linked list.
– Array elements can not be added, deleted once it is declared. The nodes in the linked list can be added and deleted from the list.

Programming Questions:

Q: Write a program to check given number is prime or not.

Q:  Write a program to swap 2 numbers without using third variable.

Q: Write a program to print Fibonacci series using recursion.

 

Q: write a program to convert a decimal number into binary number.

Q: wrote a program to print hello without using any semicolon.

 

Q: What is the difference between pass by value and pass by reference?

A: The major difference between call by value and call by reference is that in call by value a copy of actual arguments is passed to respective formal arguments. While, in call by reference the location (address) of actual arguments is passed to formal arguments, hence any change made to formal arguments will also reflect in actual arguments.

EXAMPLE:
pass by value:

pass by reference:

 

Q: write a program to find factorial of a given number.

 

For basics of C programming you can purchase book by Yashwant Kantekar.

Let Us C – Yashwant Kanetkar
Let Us C Solutions – Yashwant Kanetkar

     

 

You may be interested in :

Sharing is caring: