1/4
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
What keyword is used to declare a constant variable in C?
The const
keyword.
What happens if you try to modify a const
variable after assignment?
The compiler generates an error, such as "expression must be a modifiable lvalue" or "assignment of read-only variable".
Why should you use const
variables in your code?
To improve code readability and prevent unintended modifications of values that should remain constant.
What is an example of declaring a constant integer in C?
const int MAX_VALUE = 100;
What is the output of the following C program?
#include <stdio.h>
int main() {
const int MAX_VALUE = 100;
printf("Max value: %d\n", MAX_VALUE);
}
Max value: 100