MCQs on Conditional Statements & Loops - C Programming Multiple Choice questions with answers
Questions
11
If the following loop is implemented
void main()
{
int num = 0;
do
{
- - num;
printf (“%d”, num);
num ++;
}
while (num >=0);
}
Answer: Option [C]
12
Consider the following code snippet
marks = 80;
switch (marks)
{
case 60:
grade = ‘C’;
break;
case 70:
grade = ‘B’;
break;
case 80:
grade = ‘A’;
break;
default:
grade = ‘E’;
}
What is the value of ‘grade’ after the switch statement is executed?
Answer: Option [A]
⭐ Make GKSeries Your Preferred Source on Google
Add GKSeries as Preferred Source
13
Consider the following program fragment:
switch (input)
{
case ‘1’: printf (“one”);
case ‘3’: printf (“three”);
case ‘4’: printf (“five”);
default: printf (“odd”); break;
}
What will be printed when input is ‘3’?
Answer: Option [B]
14
Consider the following code fragment
for(digit = 0; digit < 9; digit++)
{
digit = 2*digit;
digit - -;
}
How many times the loop will be executed?
Answer: Option [A]
15
The following program segment
{
int sum, index;
index = 50;
while (index > = 0)
{
sum =sum/index;
-index;
}
}
Answer: Option [B]
16
The output of the following code segment will be
char x = ‘B’
switch (x)
{
case ‘A’ : printf (“a”);
case ‘B’ : printf (“b”);
default : printf (“c”);
}
Answer: Option [D]