NEW
Font size
WorksheetsMCQs on Identifiers and Variables in C
Total questions: 20
Worksheet time: 7mins
Which of the following is a valid identifier in C?
123name
student_name
student name
%marks
An identifier in C can start with:
A digit
A letter or underscore
A special symbol
A space
Which identifier is invalid?
totalMarks
_student
student_123
student name
How many characters of an identifier are usually recognized by most C compilers?
8
16
31
Unlimited
Which of the following cannot be used as an identifier?
balance
int
_count
student123
Why do we avoid starting an identifier with underscore (`_`)?
It is invalid
It is reserved for system/library usage
Compiler error occurs
It makes program slower
Which of these identifiers is correct?
salary$
_marks
student id
9count
Which of the following is not allowed in identifiers?
Digits
Letters
White spaces
Underscore
Which keyword is reserved and cannot be used as identifier?
count
main
while
result
Identifier names in C are:
Case-insensitive
Case-sensitive
Always uppercase
Always lowercase
A variable in C is:
A fixed value
A reserved keyword
A data storage location with a name
A constant
Which of the following is a correct variable declaration?
int = num;
num int;
int num;
integer num;
Which variable declaration is valid?
float salary = 5000;
char grade = A;
int emp_num = seven;
double 2marks;
Variables must be declared:
After they are used
Before they are used
Only at end of program
It is optional in C
What happens if a variable is declared but not initialized?
It will contain zero
It will contain garbage value
Compiler error
It becomes constant
Which is the correct initialization?
int a = 5;
int = 5 a;
a int = 5;
5 = int a;
Which of the following statements is correct?
A variable can have multiple data types
A variable must be declared with a data type
A variable cannot be initialized at declaration
A variable name can contain spaces
Which of the following is a valid character variable initialization?
char grade = "A";
char grade = 'A';
char grade = A;
char = grade 'A';
Which is the correct way to declare and initialize multiple variables in one line?
int a, b=5, c=10;
int a=5 b=10 c=15;
int a=5, int b=10, int c=15;
int (a=5, b=10, c=15);
The statement `float salary;` means:
Reserve memory to store decimal values
Assign value 0 to salary
Reserve memory for integer only
Store characters in salary
