Professional Documents
Culture Documents
C Interview Questions
C Interview Questions
C Interview Questions
A header file is a file with extension .h which contains C function declarations and macro
definitions. You request to use a header file in your program by including it with the C
preprocessing directive #include, like you have seen inclusion of stdio.h header file, which
comes along with your compiler.
#include <stdio.h>
int main()
int n;
scanf("%d", &n);
return 0;
if (n >= 1)
return n*multiplyNumbers(n-1);
else
return 1;
}
4.What is void in C?
‘void’ is used as a function return type, it indicates that the function does not return a
value.
Basically the type of data that it points to is can be any. If we assign address of char data
type to void pointer it will become char Pointer, if int data type then int pointer and so on.
Any pointer type is convertible to a void pointer hence it can point to any value.
#include<stdio.h>
int main() {
int a = 7;
float b = 7.6;
void *p;
p = &a;
p = &b;
return 0;
● Arithmetic Operators
● Relational Operators
● Logical Operators
● Bitwise Operators
● Assignment Operators
● Unary Operators
● Tenary or conditional operator(?:)…Syntax : condition ? (true_statement) :
(false_statement);
‘&’ is bitwise operator used to perform ‘AND’ operation bitwise between two numbers,
whereas ‘&&’ is logical operator used to become true, both of the statements must be
true. If one of them is false, it becomes false.
break causes the innermost enclosing loop or switch to be exited immediately where as
the continue statement is used when we want to skip one or more statements in loop's
body and to transfer the control to the next iteration.
● The variables which are having scope/life throughout the program are called global
variables.
● Global variable is defined outside the main function. So, this variable is visible to
main function and all other sub functions.
● Data types in C language are defined as the data storage format that a variable can
store a data to perform a specific operation.
● Data types are used to define a variable before to use in a program.
● Size of variable, constant and array are determined by data types.
14.What is compiler?
● Compiler is a program that converts high level language into machine readable
code. This process is called compilation. Eg. gcc, Microsoft Visual studio
An array is a collection of fixed number of values of a single type. That is, you need to
declare the size of an array before you can use it.
Sometimes, the size of array you declared may be insufficient. To solve this issue, you can
allocate memory manually during run-time. This is known as dynamic memory
allocation in C programming.
There are 4 library functions defined under <stdlib.h> makes dynamic memory allocation
in C programming. They are malloc(), calloc(), realloc() and free().
The name malloc stands for memory The name calloc stands for contiguous allocation.
allocation.
malloc() takes one argument that calloc() take two arguments those are: number of
is, number of bytes. blocks and size of each block.
‘++a” is called prefixed increment and the increment will happen first on a variable. ‘a++'
is called postfix increment and the increment happens after the value of a variable used for
the operations.
Modifier is a prefix to the basic data type which is used to indicate the modification for
storage space allocation to a variable.
● Short
● Long
● Signed
● Unsigned
● long long
Programs to remember:
● Palindrome
● Swapping of two numbers using functions
● Factorial using recursion
● Armstrong number
● Perfect number
● Print your name in vertical like
Input : TCS
Output:
T
C
S