# TCS Techincal Questions with Solutions Set -1

1.Which of this is used to skip one iteration:
A) break
B) continue
C) goto
D) return

2.Which of the following does not require to include math.h header file?
A) pow()
B) rand()
C)sqrt()
D) sinh()

3.Which has the highest precision?
A. float
B. double
C. unsigned long int
D. Long int

4.Choose the correct 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

5.Predict the output of following code:
main()
{
int a=10,x;
x= a– + ++a;
printf(“%d”,x);
}
A) 19
B) 20
C) 22
D) 23

6.Guess the output:
main()
{
printf(“%d”, sizeof(‘a’));
//same as → sizeof(97)
}
A) 2 or 4 —
B) 1 or 3
C) Garbage value
D) ASCII value of a
Explaination:
sizeof takes ascii value of character and determines number of bytes required by it. Ascii is number, Number is of type int. so integer requires either 2 in 16 or 4 in 32 bit machine

7.Predict the output of following code:
main()
{
int a=b=c=d=10;
printf(“%d,%d,%d,%d”,a,b,c,d);
}
A) Error
B) 10,10,10,10
C) Garbage Value,Garbage Value,Garbage Value,10
D) Garbage Value,Garbage Value,Garbage Value,Garbage Value
Explaination: error: ‘b’ , ‘c’, ‘d’ undeclared

8.Select the missing statement?
#include
long int fact(int n);
int main()
{
\\missing statement
}
long int fact(int n)
{
if(n>=1)
return n*fact(n-1);
else
return 1;
}
A) printf(“%ll\n”,fact(5));
B) printf(“%u\n”,fact(5));
C) printf(“%d\n”,fact(5));
D) printf(“%ld\n”,fact(5));

9. If a function’s return type is not explicitly defined then it’s default to ______ (In C).
A) int
B) float
C) void
D) Error