C Variables MCQ Questions and Answers

1. What is a variable in C programming?

a) A type of function
b) An operator
c) A storage location with a name
d) A keyword in C

2. Which of the following is a valid variable name in C?

a) 1number
b) _number
c) number1
d) number-1

3. How do you declare an integer variable named 'age' in C?

a) int age;
b) integer age;
c) age int;
d) declare age as integer;

4. What will be the initial value of an uninitialized integer variable in C?

a) 0
b) A random number
c) 1
d) Null

5. How do you initialize a float variable 'temp' with the value 23.5 in C?

a) float temp = 23.5;
b) float 23.5 = temp;
c) float temp = 23.5f;
d) initialize temp with 23.5;

6. Which of the following is the correct way to declare a character variable with the value 'A'?

a) char letter = 'A';
b) char letter = "A";
c) character letter = 'A';
d) letter = 'A';

7. What is the correct syntax to declare a constant integer variable 'MAX' with value 100 in C?

a) constant int MAX = 100;
b) const int MAX = 100;
c) int constant MAX = 100;
d) #define MAX 100

8. Which of the following is used to define a symbolic constant in C?

a) const
b) define
c) #define
d) #const

9. What is the default value of a global integer variable in C?

a) 0
b) 1
c) A random number
d) Null

10. What data type would you use to store a person's first name in C?

a) int
b) float
c) char array
d) bool

11. How do you declare an array of 10 integers in C?

a) int array[10];
b) array int[10];
c) int[10] array;
d) array[10] int;

12. Which of the following operators is used to access the value at a specific address in a pointer?

a) &
b) *
c) ->
d) ::

13. What is the output of the following C code: int x = 10; printf("%d", x);

a) 10
b) x
c) %d
d) Error

14. What is the purpose of the 'sizeof' operator in C?

a) To check the size of a variable
b) To allocate memory
c) To compare two values
d) To find the length of a string

15. What is the correct way to assign a new value to an existing variable in C?

a) int x;
b) int x;
c) x = 5;
d) assign x = 5;

16. What is the scope of a local variable in C?

a) Throughout the program
b) Only within the function it is declared
c) Throughout the file
d) Global

17. Which of the following is not a valid data type in C?

a) int
b) string
c) float
d) double

18. What does the following declaration mean? int *ptr;

a) ptr is an integer
b) ptr is a pointer to an integer
c) ptr is a function returning an integer
d) ptr is an array of integers

19. What is the result of the following expression in C: 5 + 3 * 2?

a) 16
b) 11
c) 13
d) 8

20. What is the purpose of the 'return' statement in a C function?

a) To exit the program
b) To return control to the calling function
c) To declare a variable
d) To print a value

Comments