TCS Computer Programming MCQ Questions – 5

Q1: What is the output of this C code?

#include <stdio.h>

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

Q2. 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.

Q3: 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 typecasted 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

Q4 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

Q5: 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