C Technical Questions with Answer

Hello friends in this post we are going to discuss about C Technical Questions with Answer | C Technical Question Answer Dumps | C Technical Interview Questions with Answer

Q.A pointer variable can be

  1. Changed within function.
  2. Assigned an integer value.
  3. None of these
  4. Passed to a function as argument.
    Correct Op: 4

Q. Which of the following uses structure?

  1. Linked Lists
  2. Array of structures
  3. All of these
  4. Binary Tree
    Correct Op: 3

Q. Strings are character arrays. The last index of it contains the null-terminated character

  1. \t
  2. \1
  3. \0
  4. \n
    Correct Op: 3

Q. Which of the following is a collection of different data types?

  1. String
  2. Structure
  3. Array
  4. Files
    Correct Op: 2

Q. What function should be used to free the memory allocated by calloc() ?

  1. free();
  2. malloc(variable_name, 0)
  3. dealloc();
  4. memalloc(variable_name, 0)
    Correct Op: 1

Q. In the standard library of C programming language, which of the following
header file is designed for basic mathematical operations?

  1. conio.h
  2. stdio.h
  3. math.h
  4. Dos.h

Correct Op: 3

Q. int **ptr; is?

  1. Pointer to integer
  2. None of these
  3. Pointer to pointer
  4. Invalid declaration
    Correct Op: 3

Q8. Which of the following special symbol allowed in a variable name?

  1. (underscore)
  2. – (hyphen)
  3. | (pipeline)
  4. * (asterisk)
    Correct Op: 1

Q9. All keywords in C are in

  1. Uppercase letters
  2. None of these
  3. Lowercase letters
  4. Camel Case letters

Correct Op: 3

Q10. What should the program below print?

void myfunc(char** param){
int main(){
char* string = (char*)malloc(64);
strcpy(string, “hello_World”);
printf(“%s\n”, string);
// ignore memory leak for sake of quiz
return 0;

  1. hello_World
  2. ello_World
  3. lo_World
  4. llo_World

Correct Op: 1

Q: What is the output of this C code?

void main()
int k = 5;
int *p = &k;
int **m = &p;
printf(“%d%d%d\n”, k, *p, **p);

a) 5 5 5
b) 5 5 junk
c) 5 junk junk
d) Compile time error

Correct op: D
1) It would have been 5 5 5 if it were **m and not **p.

Q. Which of the following statements about stdout and stderr are true?

a) They both are the same
b) Run time errors are automatically displayed in stderr
c) Both are connected to the screen by default.
d) stdout is line buffered but stderr is unbuffered.

Correct Op: D
Explanation –
a) False. b) Not by default. c) Not by default. d) True.

Q: Given the below statements about C programming language:
1) main() function should always be the first function present in a C program file
2) all the elements of an union share their memory location
3) A void pointer can hold address of any type and can be typcasted to any type
4) A static variable hold random junk value if it is not initialised

Which of the above are correct statements?
A) 2,3
B) 1,2
C) 1,2,3
D) 1,2,3,4
Correct Op – A
In a file you can write a function before main() – False

all the elements of an union share their memory location – True.
A void pointer can hold address of any type and can be typcasted to any type –
Static value – False as value is 0
In C, if an object that has static storage duration is not initialized explicitly, then:
— if it has pointer type, it is initialized to a NULL pointer;
— if it has arithmetic type, it is initialized to (positive or unsigned) zero;
— if it is an aggregate, every member is initialized (recursively) according to these
— if it is a union, the first named member is initialized (recursively) according to
these rules.

Q If a function is defined as static, it means
A) The value returned by the function does not change
B) all the variable declared inside the function automatically will be assigned
initial value of zero
C) It should be called only within the same source code / program file.
D) None of the other choices as it is wrong to add static prefix to a function
Correct Op: C
Access to static functions is restricted to the file where they are declared.
Therefore, when we want to restrict access to functions, we make them static.

Q: Comment on the below while statement=

while (0 == 0) { }
A) It has syntax error as there are no statements within braces {}
B) It will run forever
C) It compares 0 with 0 and since they are equal it will exit the loop immediately
D) It has syntax error as the same number is being compared with itself
Correct Op: B
while( 0==0) {} is equivalent to while(1) {}

Q.What will happen if in a C program you assign a value to an array element
whose subscript exceeds the size of array?

A. The element will be set to 0.
B. The compiler would report an error.
C. The program may crash if some important data gets overwritten.
D. The array size would appropriately grow.
Answer: Option C
If the index of the array size is exceeded, the program will crash. Hence “option c”
is the correct answer. But the modern compilers will take care of this kind of

Q.What does the following declaration mean?

int (*ptr)[10];
A.ptr is array of pointers to 10 integers
B.ptr is a pointer to an array of 10 integers

C.ptr is an array of 10 integers
D.ptr is an pointer to array
Answer: Option B

In C, if you pass an array as an argument to a function, what actually gets passed?

A.Value of elements in array
B.First element of the array
C.Base address of the array
D.Address of the last element of array
Answer: Option C
The statement ‘C’ is correct. When we pass an array as a function argument, the
base address of the array will be passed.

What will be the output of the program ?

int main()
int a[5] = {5, 1, 15, 20, 25};
int i, j, m;
i = ++a[1];
j = a[1]++; m = a[i++];
printf(“%d, %d, %d”, i, j, m);
return 0;

A.2, 1, 15
B.1, 2, 5
C.3, 2, 15
D.2, 3, 20
Answer: Option C
Step 1: int a[5] = {5, 1, 15, 20, 25}; The variable arr is declared as an integer array
with a size of 5 and it is initiapzed to
a[0] = 5, a[1] = 1, a[2] = 15, a[3] = 20, a[4] = 25 .
Step 2: int i, j, m; The variable i,j,m are declared as an integer type.
Step 3: i = ++a[1]; becomes i = ++1; Hence i = 2 and a[1] = 2
Step 4: j = a[1]++; becomes j = 2++; Hence j = 2 and a[1] = 3.
Step 5: m = a[i++]; becomes m = a[2]; Hence m = 15 and i is incremented by 1(i++
means 2++ so i=3)
Step 6: printf(“%d, %d, %d”, i, j, m); It prints the value of the variables i, j, m
Hence the output of the program is 3, 2, 15

Q.Is there any difference int the following declarations?
int fun(int arr[]);

int fun(int arr[2]);

Answer: Option B
No, both the statements are same. It is the prototype for the function fun() that
accepts one integer array as an parameter and returns an integer value.

Q.Are the expressions arr and &arr same for an array of 10 integers?
Answer: Option B
Both mean two different things. arr gives the address of the first int, whereas the
&arr gives the address of array of ints.

Q.Which of the fplowing statements should be used to obtain a remainder after
dividing 3.14 by 2.1?

A.rem = 3.14 % 2.1;
B.rem = modf(3.14, 2.1);
C.rem = fmod(3.14, 2.1);
D.Remainder cannot be obtain in floating point division.
Answer: Option C

fmod(x,y) – Calculates x modulo y, the remainder of x/y.
Q.This function is the same as the modulus operator. But fmod() performs floating
point divisions. What are the types of pnkages?

A.Internal and External
B.External, Internal and None
C.External and None
Answer: Option B
External pnkage-> means global, non-static variables and functions.
Internal pnkage-> means static variables and functions with file scope.
None pnkage-> means Local variable

Q.Which of the fplowing special symbp allowed in a variable name?
A.* (asterisk)
B.| (pipepne)
Answer: Option D

Variable names in C are made up of letters (upper and lower case) and digits. The
underscore character (““) is also permitted. Names must not begin with a digit. Examples of vapd (but not very descriptive) C variable names: => foo => Bar => BAZ => foo_bar => _foo42 =>
=> QuUx

Q.Is there any difference between following declarations?
1 : extern int fun();
2 : int fun();

A.Both are identical
B.No difference, except extern int fun(); is probably in another file
C.int fun(); is overrided with extern int fun();
D.None of these
Answer: Option B
extern int fun(); declaration in C is to indicate the existence of a global function
and it is defined externally to the current module or in another file.

int fun(); declaration in C is to indicate the existence of a function inside the
current module or in the same file.

Leave a Reply

Your email address will not be published. Required fields are marked *