TCS - C Programming Concept MCQ - Set 3

TCS NQT Programming MCQ 

TCS NQT Programming MCQ - SimpleWay2Code



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

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

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

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

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


C MCQ - SimpleWay2Code


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

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

Ques. Select the missing statement?
#include<stdio.h> 
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));

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

Ques. How many times the below loop will be executed?
#include<stdio.h> 
int main()
{
int i;
        for(i=0;i<5;i++) 
       printf("Hello\n"); 
}

A) 5
B) 1
C) 0
D) 3



Also check Chapterwise C - MCQ .

Post a Comment

1 Comments

  1. For the sizeof('a') its actually 1
    I compiled in turbo c it produced 1.
    since tcs mcqs are based on programs compiled in turbo c its better to go with 1.

    ReplyDelete