Examveda
Examveda

What is the purpose of the 'const' keyword in C?

A. Declare a constant

B. Declare a variable

C. Define a function

D. Initialize a pointer

Answer: Option A

Solution(By Examveda Team)

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.

This Question Belongs to C Program >> C Fundamentals

Join The Discussion

Related Questions on C Fundamentals