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


Introduction

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


techstudy.org

HP 15 Core i3 7th gen Laptop(4GB, 1TB HDD, Windows 10) | Rs. 31,490

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


  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5. const int a=20; //declare and assign constant integer
  6. int *p; //declare integer pointer
  7. p=&a; //assign address into pointer p
  8.  
  9. printf("Before changing - value of a: %d",a);
  10.  
  11. //assign value using pointer
  12. *p=40;
  13.  
  14. printf("\nAfter changing - value of a: %d",a);
  15. printf("\nValue has changed.");
  16.  
  17. return 0;
  18. }
  19.  

Result

C language techstudy.org

     





Related Topics




Popular Posts