How can we declare constant variable in C?
Answers
Answered by
3
Answer:
Variables can be declared as constants by using the “const” keyword before the datatype of the variable. The constant variables can be initialized once only. The default value of constant variables are zero. A program that demonstrates the declaration of constant variables in C using const keyword is given as follows.
Answered by
8
Required Answer:-
Correct Question:
- How can we declare constant in C language?
Answer:
To declare constants in C language, the const keyword is used. For Example, if we want to declare π as constant, then we can write,
const double pi = 3.141590;
Now, variable pi is a constant. Now, f we try to change the value of pi, an error will occur.
pi = 0.0; // error occurs.
Refer to the attachment.
•••♪
Attachments:
Similar questions