wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

CODETRONICS WORKSHOP TEST

Total questions: 30

Worksheet time: 15mins

Name
Class
Date
1.

What is the output of this statement "printf("%d", (a++))"?

a)

The value of (a + 1)

b)

The current value of a

c)

Error message

d)

Garbage

2.

How many times will the following loop execute? for(j = 1; j <= 10; j = j-1)

a)

Forever

b)

Never

c)

0

d)

1

3.

Which one of the following is a loop construct that will always be executed once?

a)

for

b)

while

c)

switch

d)

do while

4.

How many bytes does "int D" use?

a)

0

b)

1

c)

2 or 4

d)

10

5.

Find a correct C Keyword below.

a)

work

b)

permanent

c)

constant

d)

case

6.

Which of the following loop types is not supported in C?

a)

for

b)

while

c)

do-while

d)

foreach

7.

Who defines the user-defined function?

a)

Compiler

b)

Computer

c)

Compiler library

d)

Users

8.

What does the 'continue' statement do in a loop in C?

a)

Terminates the loop immediately

b)

Skips the current iteration and proceeds to the next iteration

c)

Pauses the loop temporarily

d)

None of the above

9.

In C, what is the purpose of the break statement in a switch statement?

a)

It terminates the program.

b)

It exits the current loop.

c)

It transfers control to a specific case label.

d)

It continues to the next case label.

10.

Which looping construct is best when the number of iterations is known beforehand?

a)

while loop

b)

do-while loop

c)

for loop

d)

All are equally good

11.

In C, which operator is used for logical AND?

a)

&&

b)

&

c)

and

d)

AND

12.

How is user input read in C using the scanf() function?

a)

scanf("format string", &variable);

b)

scanf(&variable, "format string");

c)

scanf(format string, variable);

d)

scanf(&variable);

13.

Which header file should be included to use the printf() and scanf() functions in C?

a)

stdlib.h

b)

stdio.h

c)

string.h

d)

math.h

14.

Who is known as the founder of the C language?

a)

Ken Thompson

b)

Dennis Ritchie

c)

Martin Richard

d)

Kernighan

15.

Which of the following is not an arithmetic operation?

a)

a * = 10;

b)

a / = 10;

c)

a ! = 10;

d)

a % = 10;

16.

What are the entities whose values can be changed called?

a)

Constants

b)

Variables

c)

Modules

d)

Tokens

17.

Which is correct with respect to size of the datatypes?

a)

char > int > float

b)

int > char > float

c)

char < int < double

d)

double > char > int

18.

What will be the output of the following C code? #include void main() { int x = 5; if (x < 1); printf("Hello"); }

a)

Nothing

b)

Run time error

c)

Hello

d)

Varies

19.

Which datatype can accept the switch statement?

a)

int

b)

char

c)

long

d)

all of the mentioned

20.

Which of the following statement is TRUE for switch statement?

a)

It is mandatory to include at least one case in the switch block.

b)

It is optional to include a default case.

c)

There is no restriction on the number of cases that can be included in as switch statement.

d)

None of the above

21.

C programming body of a switch statement must consist of:

a)

A case labeled statement

b)

default labeled statement

c)

A statement

d)

A loop

22.

C language is known for its feature of "portability." What does portability refer to in this context?

a)

The ability to run code on any platform without modification

b)

The ability to write code without any bugs

c)

The ability to write code quickly

d)

The ability to create complex graphics

23.

How many keywords are there in C Language?

a)

30

b)

22

c)

32

d)

36

24.

Identify wrong C keyword below

a)

auto, double, int, struct

b)

break, else, long, switch

c)

case, enum, register, typedef

d)

char, extern, intern, return

25.

What is the purpose of the 'return' statement in a function in C?

a)

To exit the program

b)

To return a value to the caller

c)

To pause the execution

d)

To declare a variable

26.

What is the size of a float data type in C?

a)

2 bytes

b)

4 bytes

c)

8 bytes

d)

16 bytes

27.

What does the 'sizeof' operator do in C?

a)

Returns the size of a variable

b)

Returns the size of a data type

c)

Both of the above

d)

None of the above

28.

Which of the following is not a valid data type in C?

a)

float

b)

double

c)

decimal

d)

char

29.

a)

10 11 12 13 14

b)

10 10 10 10 10

c)

0 1 2 3 4

d)

Compilation Error

30.

What will be the output of the following code? #include void main() { int a = 5; printf("%d", a-- + --a); }

a)

8

b)

9

c)

7

d)

6