Q:

Write C program to change the value of constant integer using pointers

belongs to collection: C language Pointer Exercises

0

Write 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

I have used Code::blocks 12 compiler for debugging purpose. But you can use any C programming language compiler as per your availability.

#include <stdio.h>
 
int main()
{
    const int a=20;     //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=40;
 
    printf("\nAfter  changing - value of a: %d",a);
    printf("\nValue has changed.");
 
    return 0;
}

Result:

Before changing - value of a: 20

After  changing - value of a: 40

Value has changed.

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

total answers (1)

Write C Program to find length of string using poi... >>
<< Write C Program input and print array elements usi...