Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

C Loops

Total questions: 25

Worksheet time: 13mins

Name
Class
Date
1.

How many loops are there in C?

a)

2

b)

3

c)

4

d)

1

2.

What is currect syntax of for loop?

a)

for(initialization;condition; increment/decrement)

b)

for(increment/decrement; initialization; condition)

c)

for(initialization, condition, increment/decrement

d)

None of These

3.

The statement i++; is equivalent to

a)

i = i + i;

b)

i = i + 1;

c)

i = i - 1;

d)

i --;

4.

What's wrong? for (int k = 2, k <=12, k++)

a)

the increment should always be ++k

b)

the variable must always be the letter i when using a for loop

c)

there should be a semicolon at the end of the statement

d)

the commas should be semicolons

5.

If you want a user to enter exactly 20 values, which loop would be the best to use?

a)

while

b)

switch

c)

do-while

d)

for

6.

What does <= mean?

a)

less than

b)

greater than

c)

less than or equal to

d)

greater than or equal to

7.

Which of the following is NOT a comparison operator in C++ language?

a)

>

b)

<=

c)

=

d)

==

8.

What will be the output of this code?

a)

OK

b)

KO

c)

Depends on compiler

d)

Depends on standard

9.

What is the value of "z" in this code?

a)

The value of z is 10

b)

The value of z is 15

c)

The value of z is 15.6

d)

The value of z is 16

10.

What is output of below program?


int main()

{

int i,j,count;

count=0;

for(i=0; i<5; i++)

{

count++;

}

printf("%d",count);

return 0;

}

a)

5

b)

4

c)

1

d)

0

11.

Number of Keywords present in C Language are .?

a)

32

b)

34

c)

62

d)

64

12.

What is the only function all C programs must contain?

a)

start()

b)

system()

c)

main()

d)

Program()

13.

What is the output of C Program.?

int main()

{

int a;

for(a=25; a <= 27; a++)

{

printf("%d ", a);

}

return 0;

}

a)

25 25 25

b)

25 26 27

c)

27 27 27

d)

Compiler error

14.

What is the result after execution of the following code if a is 10, b is 5, and c is 10?

if ((a > b) && (a <= c))

a = a + 1;

else

c = c+1;

a)

a = 10, c = 10

b)

a = 11, c = 10

c)

a = 10, c = 11

d)

a = 11, c = 11

15.

In switch statement Case Labels must ends with --------

a)

;

b)

:

c)

,

d)

}

16.

----------------- are used in C programming to manipulate the data at bit level

a)

Logical operator

b)

Bitwise operator

c)

Additional operators

d)

None of the above

17.

Every C statement ends with ------------?

a)

.

b)

;

c)

,

d)

}

18.

4. Name the one which is not a looping statement

a)

for

b)

while

c)

do-while

d)

if

19.

The conditional operator are also known as

a)

Relational operator

b)

Binary operator

c)

Ternary operator

d)

Chary operator

20.

What will be the output of following code- for(int i = 1; i < 5; i++ )

{

printf("%d",i);

}

a)

13

b)

135

c)

1234

d)

12345

21.

Select different parts of "for" looping statement-

a)

Initialization part

b)

Condition Part

c)

Update part

d)

All of these

22.
If there is more than one statement in the block of a for loop, which of the following must be placed at the beginning and the ending of the loop block? a.  b.  c. . d. 
a)
parentheses ( )
b)
braces { }
c)
brackets [ ]
d)
arrows < >
23.

This loop starts counting down from 10

a)

for(int i=10; i>0; i--)

b)

int i = 10;

c)

count=10;

d)

for(int i=0; i>0; i--)

24.

Statement lets you run code many times while a condition is true

a)

When

b)

Condition

c)

for

d)

Parentheses

25.

What output is produced by the following segment of code:

for (int i = 0; i < 12; i++)

printf("%d ", i );

a)

0 1 2 3 4 5 6 7 8 9 10 11 12

b)

0 1 2 3 4 5

6 7 8 9 10 11

c)

1 2 3 4 5 6 7 8 9 10

d)

1 2 3 4 5 6 7 8 9

e)

Infinite Loop