constants Questions and Answers

Practice Mode
Showing 10 of 30 questions
Q11
Which of the following is a valid way to define a constant in C?
  • A const int x = 5;
  • B constant int x = 5;
  • C int const x = 5;
  • D Both 1 and 3
Answer: Option D
Explanation: const keyword is used to define constants in C
Q12
What is the correct way to define a symbolic constant in C?
  • A #define MAX 100
  • B const MAX = 100;
  • C constant MAX 100
  • D def MAX 100
Answer: Option A
Explanation: #define preprocessor directive is used for symbolic constants
Q13
Which keyword is used to define constants in C?
  • A constant
  • B fixed
  • C const
  • D final
Answer: Option C
Explanation: const keyword is used for defining constants
Q14
What will be the output of: #define PI 3.14 printf("%f", PI);
  • A 3.14
  • B 0
  • C PI
  • D Error
Answer: Option A
Explanation: PI will be replaced by 3.14 during preprocessing
Q15
Which of the following is NOT a valid constant definition?
  • A const int x = 10;
  • B #define Y 20
  • C const float z;
  • D int const w = 30;
Answer: Option C
Explanation: Missing semicolon makes this invalid
Q16
What is the value of a const variable that is not initialized?
  • A 0
  • B Garbage value
  • C Compiler error
  • D NULL
Answer: Option C
Explanation: const variables must be initialized at declaration
Q17
Which of the following is a string constant?
  • A "Hello"
  • B 'A'
  • C 100
  • D 3.14
Answer: Option A
Explanation: Double quotes define string constants
Q18
What is the type of constant 100?
  • A int
  • B long
  • C char
  • D float
Answer: Option A
Explanation: Default type for integer constants is int
Q19
How to define a constant pointer in C?
  • A int const *ptr;
  • B const int *ptr;
  • C int *const ptr;
  • D const *int ptr;
Answer: Option C
Explanation: const before * makes pointer constant
Q20
Which of these is a character constant?
  • A 'A'
  • B "A"
  • C A
  • D 65
Answer: Option A
Explanation: Single quotes define character constants
Questions and Answers for Competitive Exams Various Entrance Test