What is Comments in C Language?

A constant is a fixed value that can't be change during the execution of the program. its value always fix.

There are two ways to define constant in C programming.

  • const keyword
  • #define preprocessor

  • C const keyword :-

    The const keyword is used to define constant in C programming.

    #include
    int main(){
    const float PI=3.14;
    printf("The value of PI is: %f",PI);
    return 0;
    }

    If you try to change the the value of PI, it will render compile time error.

    #include <stdio.h>
    int main(){
    const float PI=3.14;
    PI=4.5;
    printf("The value of PI is: %f",PI);
    return 0;
    }

    The #define Preprocessor :-

    #define identifier value

    #include <stdio.h>
    #define LENGTH 10
    #define WIDTH 5
    #define NEWLINE '\n'
    int main() {
    int area;
    area = LENGTH * WIDTH;
    printf("value of area : %d", area);
    printf("%c", NEWLINE);
    return 0;
    }





    Previous Next

    Trending Tutorials




    Review & Rating

    0.0 / 5

    0 Review

    5
    (0)

    4
    (0)

    3
    (0)

    2
    (0)

    1
    (0)

    Write Review Here


    Ittutorial