JOIN ADRE 2.0 Telegram Group

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);	
}
A A run time error will be reported
B The program will not enter into the loop
C The loop will run infinitely many times
D There will be a compilation error reported

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?

A A
B B
C C
D E

Answer: Option [A]
Advertisement
Article and Schedule Quiz Start Test!

DOWNLOAD CURRENT AFFAIRS PDF FROM APP

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’?

A Three five odd
B Three
C Three odd
D Three odd

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?

A Infinite
B 9
C 5
D 0

Answer: Option [A]
15 The following program segment

{
	int sum, index;
	index = 50;
	while (index > = 0) 
	{
		sum =sum/index;
		-index;
	}
} 
A Will give a run time error
B Will give a compilation error
C Will give a linking error
D None of the above

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”);
}
A B
B a
C C
D b

Answer: Option [D]

ADRE 2.0 FULL LENGTH MOCK TEST

Take Mock Tests

Missiles Mock Test Start Test!
SSC MTS Mock Test Start Test
IBPS CLERK MOCK TEST Start Test
SSC MTS 2022 JULY 26 Shift 1 (ENGLISH) Start Test!
SSC GD Previous Year Paper 2021 Nov 17 Shift - I (Hindi) Start Test!
SSC CGL Tier - 1 PYP 2022 April 21 Shift- 1 (ENGLISH) Start Test!
MPSC PAPER I MOCK TEST 1 (ENGLISH) Start Test!
IB Security Assistant Mock test 1 (english) Start Test!
UP POLICE CONSTABLE MOCK TEST 1 Start Test!
DELHI POLICE CONSTABLE MOCK TEST 1 (HINDI) Start Test!

Chapters

Advertisement