constants Questions and Answers

Practice Mode
Showing 10 of 30 questions
Q21
What is the advantage of using #define over const?
  • A Type checking
  • B Memory allocation
  • C Scope
  • D No memory allocation
Answer: Option D
Explanation: #define doesn't allocate memory, const does
Q22
Which constant cannot be modified?
  • A const variable
  • B #define constant
  • C Both
  • D None
Answer: Option A
Explanation: const variables cannot be modified after initialization
Q23
What is the size of const int?
  • A 1 byte
  • B 2 bytes
  • C 4 bytes
  • D Same as int
Answer: Option D
Explanation: const doesn't change the size of data type
Q24
How to make a constant floating point value?
  • A const 3.14;
  • B const float pi = 3.14;
  • C constant 3.14;
  • D float const = 3.14;
Answer: Option B
Explanation: Use const float or const double
Q25
What is the problem with: const int x; x=10;?
  • A No problem
  • B Missing semicolon
  • C Redeclaration
  • D Cannot assign to const variable
Answer: Option D
Explanation: const variables must be initialized at declaration
Q26
Which is correct for constant array?
  • A const int arr[5];
  • B int const arr[5];
  • C const arr[5];
  • D Both 1 and 2
Answer: Option D
Explanation: const applies to array elements
Q27
What does const in function parameter mean?
  • A Parameter is constant
  • B Parameter cannot be modified
  • C Parameter is read-only
  • D All of the above
Answer: Option D
Explanation: const parameter cannot be modified inside function
Q28
How to define multiple constants in one line?
  • A const int a,b,c=10;
  • B const int a=1,b=2,c=3;
  • C const int a;b;c;
  • D const int a=b=c=5;
Answer: Option B
Explanation: Multiple constants can be declared with comma separation
Q29
What is enum constant in C?
  • A Integer constant with names
  • B Floating point constant
  • C String constant
  • D Character constant
Answer: Option A
Explanation: enum defines named integer constants
Q30
Which is true about #define constants?
  • A Type checked
  • B Memory allocated
  • C No type checking
  • D Cannot be used in expressions
Answer: Option C
Explanation: #define constants have no type checking
Questions and Answers for Competitive Exams Various Entrance Test