Bird
0
0

Which of the following is the correct way to define a constant integer named MAX with value 100 in C?

easy📝 Syntax Q12 of 15
C - Variables and Data Types
Which of the following is the correct way to define a constant integer named MAX with value 100 in C?
AAll of the above
B#define MAX 100
Cconst int MAX = 100;
Dint const MAX = 100;
Step-by-Step Solution
Solution:
  1. Step 1: Review ways to define constants in C

    Constants can be defined using #define or using const keyword with variable declaration.
  2. Step 2: Check each option

    #define MAX 100 uses #define, which is valid. int const MAX = 100; uses int const, which is valid. const int MAX = 100; uses const int, also valid. So all are correct.
  3. Final Answer:

    All of the above -> Option A
  4. Quick Check:

    All methods define constants [OK]
Quick Trick: Use #define or const keyword for constants [OK]
Common Mistakes:
  • Using variable without const
  • Missing semicolon in const declaration
  • Confusing #define with variable

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Quizzes