wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

C Programming Quiz

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.

Which of the following is a valid identifier in C?

a)

2data

b)

data_1

c)

char

d)

int-value

2.

Which of the following is not a keyword in C?

a)

auto

b)

register

c)

typedef

d)

function

3.

Which data type is used to represent a single character in C?

a)

int

b)

char

c)

float

d)

double

4.

What is the size of int on a typical 32-bit system?

a)

2 bytes

b)

4 bytes

c)

8 bytes

d)

1 byte

5.

What is the purpose of keywords in C?

a)

They define user-defined variables

b)

They are used to perform operations

c)

They have special meaning and cannot be used as identifiers

d)

They define memory locations

6.

Which of the following is a valid character constant in C?

a)

'abc'

b)

"a"

c)

'a'

d)

a

7.

What is the output data type of sizeof(char) in C?

a)

int

b)

char

c)

float

d)

size_t

8.

Which of the following characters is used to indicate a preprocessor directive?

a)

@

b)

%

c)

#

d)

$

9.

Which of these is not a valid data type in standard C?

a)

float

b)

bool

c)

double

d)

long

10.

Which keyword is used to define a constant value in C?

a)

final

b)

const

c)

static

d)

define

11.

int x = 10;

if (x > 10)

printf("A");

else

printf("B");

a)

A

b)

B

c)

Error

d)

AB

12.

Which of the following is TRUE about else if ladder?

a)

Multiple else if statements can be used ✅

b)

Only one else if is allowed

c)

else if must always end with else

d)

else if works only inside switch

13.

int x = 5;

if (x < 10)

if (x > 0)

printf("Positive");

else

printf("Negative");

a)

Positive

b)

Negative

c)

Error

d)

No output

14.

Which of the following statements about nested if is correct?

a)

Nested if is not allowed in C

b)

Nested if means an if inside another if

c)

Nested if must always have else

d)

Nested if is same as switch

15.

int x = 2;

switch(x) {

case 1: printf("One"); break;

case 2: printf("Two"); break;

case 3: printf("Three"); break;

default: printf("Other");

}

a)

One

b)

Two

c)

Three

d)

Other