?
What is the purpose of the 'const' keyword in C?
Answer & Solution
Correct Answer:
Option
A
The purpose of the 'const' keyword in C is to declare a constant. When you use the 'const' keyword before a variable declaration, it indicates that the value of that variable cannot be changed once it is assigned a value. It creates an immutable constant in your code.
So, the correct answer is:
Option A: Declare a constant
Here's an example of using the 'const' keyword to declare a constant in C:
In this example, 'max_attempts' is declared as a constant integer, and its value cannot be modified after initialization.
So, the correct answer is:
Option A: Declare a constant
Here's an example of using the 'const' keyword to declare a constant in C:
const int max_attempts = 3;
In this example, 'max_attempts' is declared as a constant integer, and its value cannot be modified after initialization.
Join the Discussion
Login to post a comment or share your explanation.
Login