Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

level 2 Quiz 50 MCQs question

Total questions: 50

Worksheet time: 25mins

Name
Class
Date
1.

Which of the following is a correct way to declare an integer variable in C?

a)

int x;

b)

integer x;

c)

num x;

d)

declare int x;

2.

What is the size of int data type in C (on a 32-bit compiler)?

a)

1 byte

b)

2 bytes

c)

4 bytes

d)

8 bytes

3.

Which header file is required to use printf() and scanf()?

a)

stdio.h

b)

conio.h

c)

array.h

d)

studio.h

4.

Which symbol is used to end a statement in C?

a)

:

b)

.

c)

;

d)

,

5.

What will be the output of the following code? int a = 5; printf("%d", a++);

a)

4

b)

5

c)

6

d)

Error

6.

Which operator is used to get the address of a variable?

a)

*

b)

%

c)

&

d)

#

7.

Which of the following is a valid C identifier?

a)

2num

b)

num-1

c)

_num

d)

float

8.

Which loop is guaranteed to execute at least once?

a)

for

b)

while

c)

do-while

d)

if

9.

What is the default return type of a function in C if not specified?

a)

float

b)

char

c)

void

d)

int

10.

Which keyword is used to stop a loop immediately?

a)

exit

b)

stop

c)

break

d)

continue

11.

Which of the following is a logical operator in C?

a)

&

b)

||

c)

=

d)

+

12.

What will be the output of: printf("%d", 10 > 5 && 5 > 2);

a)

0

b)

1

c)

true

d)

false

13.

Which function is used to read a string in C?

a)

gets()

b)

scanf()

c)

fgets()

d)

All of the above

14.

Which of the following correctly declares an array of 10 integers?

a)

int arr;

b)

int arr[10];

c)

array int arr[10];

d)

int arr(10);

15.

Which symbol is used for single-line comments in C?

a)

/* */

b)

//

c)

#

d)
16.

What does the sizeof() operator return?

a)

Value of a variable

b)

Address of a variable

c)

Size in bytes

d)

Data type

17.

Which keyword is used to define a constant in C?

a)

var

b)

constant

c)

define

d)

#define

18.

Which of the following is NOT a data type in C?

a)

int

b)

float

c)

string

d)

char

19.

What is the output of: int x = 3; printf("%d", x * x);

a)

6

b)

9

c)

3

d)

Error

20.

Which statement is used to select among multiple options?

a)

if

b)

switch

c)

for

d)

goto

21.

What does continue do in a loop?

a)

Stops the loop

b)

Skips the current iteration

c)

Restarts the program

d)

Ends the program

22.

Which of the following is used to declare a pointer?

a)

int ptr;

b)

int &ptr;

c)

int *ptr;

d)

pointer int ptr;

23.

What is the output of: printf("%d", 5/2);

a)

2.5

b)

3

c)

2

d)

Error

24.

Which function is used to terminate the program?

a)

stop()

b)

break()

c)

exit()

d)

end()

25.

Which of the following is true about C language?

a)

Case-insensitive

b)

Object-oriented

c)

Platform-dependent

d)

Procedural language

26.

What is the output of the following code? int a = 5; printf("%d %d %d", a++, ++a, a);

a)

5 7 7

b)

5 6 7

c)

Undefined behavior

d)

6 7 7

27.

Which of the following correctly declares a pointer to a constant integer?

a)

int const *p;

b)

int *const p;

c)

const int *const p;

d)

int p const*;

28.

What will be the size of arr? int arr[10][20];

a)

200 bytes

b)

400 bytes

c)

800 bytes

d)

Depends on compiler

29.

What is the output? int x = 10; printf("%d", x == 10 ? 20 : 30);

a)

10

b)

20

c)

30

d)

Error

30.

Which operator has the lowest precedence?

a)

*

b)

+

c)

=

d)

++

31.

What happens if malloc() fails?

a)

Program crashes

b)

Returns 0

c)

Returns NULL

d)

Throws exception

32.

Which is not a valid storage class specifier?

a)

auto

b)

static

c)

register

d)

volatile

33.

What is the output? printf("%d", sizeof('A'));

a)

1

b)

2

c)

4

d)

Depends on compiler

34.

Which function is used to deallocate memory allocated by calloc()?

a)

free()

b)

delete()

c)

remove()

d)

dealloc()

35.

What will be printed? int i = 0; while(i < 3) printf("%d", i++);

a)

012

b)

123

c)

Infinite loop

d)

001122

36.

Which of the following is true about register variables?

a)

Address can be accessed

b)

Stored in RAM only

c)

Faster access than others

d)

Can be global

37.

What is the output? int a = 1; printf("%d", a++ + ++a);

a)

3

b)

4

c)

Undefined behavior

d)

5

38.

Which header file is required for strlen()?

a)

stdio.h

b)

stdlib.h

c)

string.h

d)

math.h

39.

What does sizeof(int*) return?

a)

Size of integer

b)

Size of pointer

c)

Size of array

d)

Compiler dependent only

40.

What is the output? int a = 10; if(a = 5) printf("YES"); else printf("NO");

a)

YES

b)

NO

c)

Error

d)

Undefined

41.

Which loop executes at least once?

a)

for

b)

while

c)

do-while

d)

if

42.

What does continue do?

a)

Terminates loop

b)

Skips current iteration

c)

Stops program

d)

Restarts loop

43.

What is the default return type of a function in C (old standard)?

a)

void

b)

float

c)

int

d)

double

44.

Which of the following cannot be used as an array index?

a)

int

b)

char

c)

float

d)

enum

45.

What is the output? printf("%d", 5/2);

a)

2.5

b)

2

c)

3

d)

Error

46.

What does #define do?

a)

Declares variable

b)

Creates macro

c)

Allocates memory

d)

Defines function

47.

Which is not a logical operator?

a)

&&

b)

||

c)

!

d)

&

48.

What will be the output? char *p = "Hello"; printf("%c", *p);

a)

H

b)

e

c)

Error

d)

Hello

49.

What does fclose() do?

a)

Deletes file

b)

Closes file stream

c)

Clears buffer

d)

Renames file

50.

Which of the following causes dangling pointer?

a)

Using NULL pointer

b)

Using freed memory

c)

Using uninitialized pointer

d)

Using array pointer