ExamVeda
Login
Home
This question belongs to C Program C Fundamentals
C Fundamentals
?

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:
const int max_attempts = 3;

In this example, 'max_attempts' is declared as a constant integer, and its value cannot be modified after initialization.
Examveda
Question posted by Examveda
Community

Join the Discussion

1 Comment
AV
AV 1 year ago
Mainly used to declare a constant