Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Control Structures

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

#include<stdio.h>

int main()

{

int num=1; //initializing the variable

while(num<=10) //while loop with condition

{

printf("%d\n",num);

num++; //incrementing operation

}

return 0;

}

a)

1 2 3 4 5 6 7 8 9 10

b)

1

2

3

4

5

6

7

8

9

10

c)

1

2

3

4

5

6

7

8

9

d)

1 2 3 4 5 6 7 8 9

2.

4) What will be the output of following program ?

#include < stdio.h >

int main()

{

int tally=0;

for(;;)

{

if(tally==10)

break;

printf("%d ",++tally);

}

return 0;

}

a)

0 1 2 3 4 5 6 7 8 9 10

b)

0 1 2 3 ... infinite times

c)

1 2 3 4 5 6 7 8 9 10

d)

1 2 3 4 5 6 7 8 9

3.

The continue statment cannot be used with

a)

for

b)

while

c)

do...while

d)

switch

4.

Which of the following is an invalid if-else statement?

a)

if (if (a == 1)){}

b)

if (a){}

c)

if ((char) a){}

d)

if (func1 (a)){}

5.

How many times i value is checked in the below code?

int main()

{

int i = 0;

do {

i++;

printf("in while loop\n");

} while (i < 3);

}

a)

2

b)

3

c)

4

d)

1

6.

What will be the output of following program?

a)

13

b)

12

c)

10

d)

15

7.

What will be the output of following program?

a)

0 1 2 3

b)

0 1 2 3 4

c)

1 2 3 4

d)

1 2 3

8.

What will be the output of following program?

a)

0 1 2 3 4 5 6 7 8 9 10

b)

0 1 2 3 ... infinite time

c)

1 2 3 4 5 6 7 8 9 10

d)

1 2 3 4 5 6 7 8 9

9.

What will be an output if option="H"?

a)

Hello

b)

Hello Welcome

c)

Hello Welcome Bye

d)

Bye

10.

What will be the output of following program

a)

5

4

b)

5 4

c)

3 4 5

d)

3

4

5