Monday, August 13, 2012

Frequently Asked C Interview Questions With Answers

Here, are some sample questions based on “C Programming language”. Read it carefully as these questions may help you in cracking any interview.


Question:1) What is the difference between declaring a variable and defining a variable?
The difference between declaring a variable and defining a variable is that while declaring a variable, the compiler verifies if the variable has been defined elsewhere but does not allocate memory for that variable. It is a kind of explicit declaration of a variable.

But while defining a variable, the compiler allocates specific memory for the variable and initializes the variable to some value. Normally, variables are declared after defining.



Question:2) Define static variable?

A static variable is a variable which has been allocated statically. i.e., the life of the variable extends as long as the entire run of the program. Static variables are global variables and find wide use in programs. It is declared as:
static datatype variable;


Question:3) What is a register variable?
Register variables are special variants of automatic variables. Register variables are stored in processor registers. The system register provides a certain control of efficiency of the program when variables are declared as register variables.

Question:4) Where is an auto variable stored?
An auto variable is stored in the computer’s main memory.

Question:5) What is meant by scope and storage allocation of a variable or function?
The scope of a variable is defined by the storage allocation of that variable. Storage allocation of a variable decides the memory part where storage space is allocated for a particular variable or function.







1 comment:

  1. Thanks for sharing this interview questions. It is really helpful, Keep sharing more like this.
    C++ Training | C Language Training | C++ programming course

    ReplyDelete

Related Posts Plugin for WordPress, Blogger...