#include <stdio.h>

int main() {
    // declare two variables.
    int x = 10, y = 20;

    // declare a constant pointer to the variable x
    int *const p = &x;

    // print the value of a through x.
    printf("The value of x is %d\n", *p);

    // modifying x through p is allowed.
    *p = 30;

    // however, modifying the pointer p is not allowed
    // p = &y;  // wrong!

    // print the updated value of x.
    printf("The updated value of x is %d\n", *p);

    return 0;
}

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: