Explore topic-wise MCQs in C Programming.

This section includes 67 Mcqs, each offering curated multiple-choice questions to sharpen your C Programming knowledge and support exam preparation. Choose a topic below to get started.

51.

Which of the following statement is correct about the program given below?


#include <studio.h>
int main ()
{
int i = 0;
for(i = 0; i <= 127; printf ("%d", i++))
;
printf (" n");
return 0;
}

A. The program would go in an infinite loop.
B. The program would output 0 1 2 ..... 126 127.
C. The program would not produce any output.
D. The program would report an error: Cannot use printf() in for loop.
Answer» C. The program would not produce any output.
52.

Which of the following is the correct output for the program given below?

#include <studio.h>
int main ( )
{
char j = 1;
while (j <= 255)
{
printf("%d",j );
j = j + 1;
}
printf ( " n");
return 0;
}

A. 1 2 3 ..... 127
B. 1 2 3 ... 255
C. 1 2 3 ..... 254 255 0 1 2 3 .. 254 255 ... infinite times
D. 1 2 3 .... 127 128 0 1 2 3 .. 127 128 .. infinite times
E. 1 2 3 .. 127 -128 -127 -126 .. -2 -1 0 1 2 .. 127 -128 -127 .. infinite times
Answer» F.
53.

In the program given below, point out the error, if any, in the for loop.

A. There should be a condition in the for loop.
B. The two semicolons should be dropped.
C. The for loop should be replaced by a while loop.
D. No error
Answer» E.
54.

Which of the following is the correct output for the program given below ?

A. 1 2 3 ..... 126 127 -128 - 127 .... -2 -1
B. Expression syntax error
C. No Output
D. 0 1 2 3 4 5
Answer» B. Expression syntax error
55.

On executing the following program how many times will the message "Thanks God" get printed?

A. Infinite times
B. 11 times
C. 0 times
D. Once
E. 10 times
Answer» D. Once
56.

How many times the while loop in the following program will get executed if a short int is 2 byte wide?

A. Infinite times
B. 255 times
C. 256 times
D. Only once
E. 254 times
Answer» C. 256 times
57.

How many times k value is checked in the following C code?

A. 1
B. 2
C. 3
D. 4
E. 5
Answer» F.
58.

The keyword break cannot be simply used within _________.

A. for
B. while
C. if-else
D. do-while
E. None of these
Answer» D. do-while
59.

How many times while loop condition is tested in the following C code snippets, if k is initialized to 0 in both the cases?

A. m+1, m
B. m+1, m+1
C. m, m
D. m, m+1
E. None of these
Answer» C. m, m
60.

Which keyword is used to exit a loop?

A. goto
B. exit
C. break
D. continue
Answer» D. continue
61.

In the program given below, point out the error, if any, in the while loop.

A. There should be a condition in the while loop.
B. There should be at least a semicolon in the while( ).
C. The while loop should be replaced by a for loop.
D. No error
Answer» B. There should be at least a semicolon in the while( ).
62.

Which of the following statement are correct about the program given below?

A. The program goes in an infinite loop.
B. The program prints all the ASCII values with its corresponding characters.
C. Error: ch should be declared as an int.
D. The program reports an error as while loop cannot take the form of a for loop.
Answer» E.
63.

Which of then following is the correct output for the program given below?

A. 5 6 7 ........ 127 0 1 2 3 4
B. 5 6 7.........65535 0 1 2 3 4
C. 5 6 ...........32767 -32766 -32765 ...... 3 4
D. No output
Answer» E.
64.

What will be the correct syntax for running two variable for loop simultaneously?

A. <pre class="prettyprint lang-c">for (k = 0, L = 0; k &lt; num, L &lt; num; k++, L += 5)<br></pre>
B. <pre class="prettyprint lang-c">for (k = 0; k &lt; num; k++){}<br> for (L = 0; L &lt; num; L += 5){}<br></pre>
C. <pre class="prettyprint lang-c">for (k = 0; k &lt; num; k++)<br> for (L = 0; L &lt; num; L += 5)<br></pre>
D. All of above
E. None of these
Answer» B. <pre class="prettyprint lang-c">for (k = 0; k &lt; num; k++){}<br> for (L = 0; L &lt; num; L += 5){}<br></pre>
65.

The C code for(;;) represents an infinite loop. It can be terminated by ___________.

A. terminate
B. abort()
C. exit(0)
D. break
E. None of these
Answer» E. None of these
66.

Which of the following cannot be used as LHS of the expression in for (expression ;expression2; expression3)?

A. macros
B. typedef
C. Function
D. Variable
E. None of these
Answer» B. typedef
67.

Which for loop has range of similar indexes of k used in for (k = 0;k < num; k++)?

A. for (k = num; k >= 0; k )
B. for (k = num-1; k>-1; k )
C. for (k = num; k>0; k )
D. for (k = num-1; k>0; k )
E. None of these
Answer» C. for (k = num; k>0; k )