
II-192 Programming Concepts
/* str = "san"; */ cannot modify a constant object
/* ++str *; / cannot modify a constant object
If pointer constant pointing to variable. We can change value of actual variable but not through the
constant pointer. The following valid and invalid operations are given.
/* k=5; */ possible
/* *pm=5; */ invalid
/* pm++; */ possible
/* *pm++; */ invalid
/* *pm=5; */ invalid
14. Write a program to declare constant pointer and modify the value.
Ans:
#include <stdio.h>
#include <conio.h>
void main()
{
int k=10;
int const *pm=&k;
clrscr();
k=40;
/* *pm=50; invalid operation */
printf("k=%d",k);
}
OUTPUT:
K=40
Explanation: In the ...