+ 2

Constants

If we don't declare a var / char as constant why does the code still function instead of printing double the value given like in the example I've gotten below without declaring that PI is a constant the output still remains the value of PI? int main() { double PI = 3.14; const double PI = 3.14; printf("%f \n", PI); return 0; }

25th Jun 2020, 4:01 AM
Simangolwa Lifwatila
Simangolwa Lifwatila - avatar
2 Answers
+ 1
We get error because a variable can be declared only once . But we can define a variable no.of times
25th Jun 2020, 5:01 AM
uday kiran
uday kiran - avatar
0
is it possible that you can elastrate with a simple code program?
25th Jun 2020, 5:11 AM
Simangolwa Lifwatila
Simangolwa Lifwatila - avatar