Two Ways to Define Constants in C
👇 Click to Claim👇
const float PI = 3.14;
#include <stdio.h>
int main(){ const float PI = 3.14; printf("The value of PI is: %f", PI); return 0;}
The value of PI is: 3.140000
#include <stdio.h>
int main(){ const float PI = 3.14; PI = 4.5; printf("The value of PI is: %f", PI); return 0;}
Compile-time error: Cannot modify const object
The #define preprocessor is also used to define constants; the content about the #define preprocessor directive will be learned in later chapters.
Programmer Technical Exchange Group
Scan the code to join the group and remember to note: city, nickname, and technical direction.