Eg: Int X 5, P &X, Q &P
Eg: Int X 5, P &X, Q &P
Eg: Int X 5, P &X, Q &P
Its a pointer variable which can hold the address of another pointer variable. It de-refers twice to
point to the data held by the designated pointer variable.
Eg: int x = 5, *p=&x, **q=&p;
for(expression-1;expression-2;expression-3) {
//set of statements
}
When control reaches for expression-1 is executed first. Then following expression-2, and if
expression-2 evaluates to non-zero set of statements and expression-3 is executed, follows
expression-2.
What is difference between including the header file with-in angular braces < > and double
quotes
If a header file is included with in < > then the compiler searches for the particular header file
only with in the built in include path. If a header file is included with in , then the compiler
searches for the particular header file first in the current working directory, if not found then in
the built in include path.
If a global variable is static then its visibility is limited to the same source code.
What is a NULL pointer?
A pointer pointing to nothing is called so. Eg: char *p=NULL;
What is the purpose of extern storage specifier?
Used to resolve the scope of global symbol.
Eg:
main() {
extern int i;
Printf(%d,i);
}
int i = 20;
If a variable is used most frequently then it should be declared using register storage specifier,
then possibly the compiler gives CPU register for its storage to speed up the look up of the
variable.
S++ or S = S+1, which can be recommended to increment the value by 1 and why?
S++, as it is single machine instruction (INC) internally.
What is a dangling pointer?
A pointer initially holding valid address, but later the held address is released or freed. Then such
a pointer is called as dangling pointer.
What is the purpose of the keyword typedef?
It is used to alias the existing type. Also used to simplify the complex declaration of the type.
What is lvalue and rvalue?
The expression appearing on right side of the assignment operator is called as rvalue. Rvalue is
assigned to lvalue, which appears on left side of the assignment operator. The lvalue should
designate to a variable not a constant.
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.
Can a program be compiled without main() function?
Yes, it can be but cannot be executed, as the execution requires main() function definition.
What is the advantage of declaring void pointers?
When we do not know what type of the memory address the pointer variable is going to hold,
then we declare a void pointer for such.
Where an automatic variable is stored?
Every local variable by default being an auto variable is stored in stack memory.
What is a nested structure?
A structure containing an element of another structure as its member is referred so.
What is the difference between variable declaration and variable definition?
Declaration associates type to the variable whereas definition gives the value to the variable.
What is a self-referential structure?
A structure containing the same structure pointer variable as its element is called as selfreferential structure.
Does a built-in header file contains built-in function definition?
No, the header file only declares function. The definition is in library which is linked by the
linker.
Explain modular programming.
Dividing the program in to sub programs (modules/function) to achieve the given task is modular
approach. More generic functions definition gives the ability to re-use the functions, such as
built-in library functions.
What is a token?
A C program consists of various tokens and a token is either a keyword, an identifier, a constant,
a string literal, or a symbol.
What is a preprocessor?
Preprocessor is a directive to the compiler to perform certain things before the actual compilation
process begins.
Explain the use of %i format specifier w.r.t scanf().
Can be used to input integer in all the supported format.
How can you print a \ (backslash) using any of the printf() family of functions.
Escape it using \ (backslash).
Does a break is required by default case in switch statement?
Yes, if it is not appearing as the last case and if we do not want the control to flow to the
following case after default if any.
When to user -> (arrow) operator.
If the structure/union variable is a pointer variable, to access structure/union elements the arrow
operator is used.
What are the different ways of passing parameters to the functions? Which to use when?
Call by value We send only values to the function as parameters. We choose this if we
do not want the actual parameters to be modified with formal parameters but just used.
How many operators are there under the category of ternary operators?
There is only one operator and is conditional operator (? : ).
Which key word is used to perform unconditional branching?
goto
What is a pointer to a function? Give the general syntax for the same.
A pointer holding the reference of the function is called pointer to a function. In general it is
declared as follows.
T (*fun_ptr) (T1,T2); Where T is any date type.
Once fun_ptr refers a function the same can be invoked using the pointer as follows.
fun_ptr();
[Or]
(*fun_ptr)();
Which operator is used to receive the variable number of arguments for a function?
Ellipses () is used for the same. A general function definition looks as follows
void f(int k,)
}
Can variables belonging to different scope have same name? If so show an example.
Variables belonging to different scope can have same name as in the following code snippet.
int var;
void f() {
int var;
}
main() {
int var;
}