Q:

C program to change the value of constant integer using pointers

belongs to collection: C pointers example programs

0

C program to change the value of constant integer using pointers

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

/*C program to change the value of constant integer using pointers.*/

#include <stdio.h>

int main()
{   
    const int a=10;     //declare and assign constant integer
    int *p;             //declare integer pointer
    p=&a;               //assign address into pointer p
     
    printf("Before changing - value of a: %d",a);
     
    //assign value using pointer
    *p=20;
     
    printf("\nAfter  changing - value of a: %d",a); 
    printf("\nWauuuu... value has changed.");
     
    return 0;
}

Output

    Before changing - value of a: 10
    After  changing - value of a: 20
    Wauuuu... value has changed.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C program to swap two numbers using pointers... >>
<< C program to print a string character by character...