Declaring constant variables in C Language

Views: 2   

If you declare a variable as constant in C Language, the value of that can't be changed during the execution of the program.
You can use the keyword const to declare variables as constants.
Following is a sample C Program shows how to declare constant variables.

#include <stdio.h>

int main() {

    const int grades = 4;

    printf("total number of grades: %d", grades);
}

If your code tries to modify constant variables, Compiler will give you an error.

On By