Q:

C program to change the value of constant integer using pointers

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)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now