Tech Study

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.

#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

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

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

Java Final keyword

Introduction : java final keyword The final keyword present in Java programming language is generally used for restricting the user. …

Read more

C++ Memory Management: new and delete

C++ Memory Management We know that arrays store contiguous and the same type of memory blocks, so memory is allocated …

Read more