This quiz covers variable declaration, initialization, data types, operations on variables, and behavior of expressions involving variables, which will test your understanding of variables in C programming with this quiz.
Question 1
What is a variable in C?
A fixed value
A memory location to store data
A keyword
A preprocessor directive
Question 2
Which of the following is the correct way to declare an integer variable in C?
x int;
int x;
integer x;
x = int;
Question 4
What is the scope of a variable declared inside a function?
Global
Block
Function
File
Question 5
Which data type would you use to store a single character in C?
int
char
string
float
Question 6
Which of the following statements is true about global variables?
They are only accessible inside one function
Their lifetime ends after the function ends
They are declared inside main()
They are accessible throughout the program
Question 7
What happens if you use an undeclared variable in C?
It gets initialized to 0
Program runs with a warning
The compiler assigns memory automatically
Compilation error
Question 8
What will be the value of a in the end?
int a = 5;
int b = a;
b = 10;
5
10
0
Garbage Value
Question 9
Which variable will have the highest scope?
Variable declared inside a loop
Variable declared inside a function
Static variable
Global variable
Question 10
Which keyword tells the compiler to look for a variable’s definition elsewhere?
extern
static
register
const
There are 13 questions to complete.