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.
Related Questions on C Fundamentals
What is the primary purpose of a function prototype in C?
A. Declare a variable
B. Declare a function
C. Define a function
D. Assign a value
What is the correct syntax for declaring a variable in C?
A. int variable_name;
B. variable_name = 5;
C. variable_name int;
D. int = variable_name;
Join The Discussion