Mock Questions For TCS NQT
Mock Questions For TCS NQT
Answer:A
Explanation: At first main function will execute and give the o/p 1 then the function is called
which give 2 as output.
Answer: D
Explanation: Even though the answer is 2, this code will compile fine only with gcc. GNU C
supports nesting of functions in C as a language extension whereas standard C compiler
doesn’t.
3. What will be the output of the following C code?
#include <stdio.h>
void m();
void n()
{
m();
}
void main()
{
void m()
{
printf("hi");
}
}
A. Hi
B. Compile time error
C. Nothing
D. Varies
Answer: B
Explanation: Function is nested and is not defined.
Answer: D
Explanation: Unknown Syntax.
5. What is the return-type of the function sqrt()?
a) int
b) float
c) double
d) depends on the data type of the parameter
Answer: c
Explanation: Sqrt() is return double because its range is high to hold value0.
6. What will be the output of the following C code having void return-type function?
#include <stdio.h>
void foo()
{
return 1;
}
void main()
{
int x = 0;
x = foo();
printf("%d", x);
}
A) 1
B) 0
C) Runtime error
D) Compile time error
Answer: D
Explanation: In given function foo() is not defined correctly.
Answer: D
Explanation: Declaration syntax must have to follow datatype var1,var2..;
Answer: A
Explanation: None.
10. Name the function that breaks a floating-point number into a normalized fraction and
an integral power of 2.
A) exp()
B) frexp()
C) Idexp()
D) modf()
Answer: B
Explanation: The frexp() function breaks a floating-point number into a normalized fraction
and an integral power of 2.