wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

MCQs on Identifiers and Variables in C

Total questions: 20

Worksheet time: 7mins

Name
Class
Date
1.

Which of the following is a valid identifier in C?

a)

123name

b)

student_name

c)

student name

d)

%marks

2.

An identifier in C can start with:

a)

A digit

b)

A letter or underscore

c)

A special symbol

d)

A space

3.

Which identifier is invalid?

a)

totalMarks

b)

_student

c)

student_123

d)

student name

4.

How many characters of an identifier are usually recognized by most C compilers?

a)

8

b)

16

c)

31

d)

Unlimited

5.

Which of the following cannot be used as an identifier?

a)

balance

b)

int

c)

_count

d)

student123

6.

Why do we avoid starting an identifier with underscore (`_`)?

a)

It is invalid

b)

It is reserved for system/library usage

c)

Compiler error occurs

d)

It makes program slower

7.

Which of these identifiers is correct?

a)

salary$

b)

_marks

c)

student id

d)

9count

8.

Which of the following is not allowed in identifiers?

a)

Digits

b)

Letters

c)

White spaces

d)

Underscore

9.

Which keyword is reserved and cannot be used as identifier?

a)

count

b)

main

c)

while

d)

result

10.

Identifier names in C are:

a)

Case-insensitive

b)

Case-sensitive

c)

Always uppercase

d)

Always lowercase

11.

A variable in C is:

a)

A fixed value

b)

A reserved keyword

c)

A data storage location with a name

d)

A constant

12.

Which of the following is a correct variable declaration?

a)

int = num;

b)

num int;

c)

int num;

d)

integer num;

13.

Which variable declaration is valid?

a)

float salary = 5000;

b)

char grade = A;

c)

int emp_num = seven;

d)

double 2marks;

14.

Variables must be declared:

a)

After they are used

b)

Before they are used

c)

Only at end of program

d)

It is optional in C

15.

What happens if a variable is declared but not initialized?

a)

It will contain zero

b)

It will contain garbage value

c)

Compiler error

d)

It becomes constant

16.

Which is the correct initialization?

a)

int a = 5;

b)

int = 5 a;

c)

a int = 5;

d)

5 = int a;

17.

Which of the following statements is correct?

a)

A variable can have multiple data types

b)

A variable must be declared with a data type

c)

A variable cannot be initialized at declaration

d)

A variable name can contain spaces

18.

Which of the following is a valid character variable initialization?

a)

char grade = "A";

b)

char grade = 'A';

c)

char grade = A;

d)

char = grade 'A';

19.

Which is the correct way to declare and initialize multiple variables in one line?

a)

int a, b=5, c=10;

b)

int a=5 b=10 c=15;

c)

int a=5, int b=10, int c=15;

d)

int (a=5, b=10, c=15);

20.

The statement `float salary;` means:

a)

Reserve memory to store decimal values

b)

Assign value 0 to salary

c)

Reserve memory for integer only

d)

Store characters in salary