study the code:
#include<stdio.h>
void main()
{
const int a=100;
int *p;
p=&a;
(*p)++;
printf("a=%dn(*p)=%dn",a,*p);
}
What is printed?
A)100,101 B)100,100 C)101,101 D)None of the
above

Answer Posted / abdur rab

the answer is c) 101, 101

a constant variable can be accessed using a pointer to
change the value because, during compilation the compiler
cannot see that the pointer is changing a contant read only
variable.

the same method can be applied over the private members in
a c++ class also.

Is This Answer Correct ?    3 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

To print the pattern 1 2 3 4 5 10 17 18 19 6 15 24 25 20 7 14 23 22 21 8 13 12 11 10 9

2199


Why is c so important?

604


How can I swap two values without using a temporary?

623


How does normalization of huge pointer works?

646


How can I recover the file name given an open stream?

557






Write a program that accept anumber in words

1258


List the different types of c tokens?

631


What is union and structure in c?

624


How can you find out how much memory is available?

620


Is malloc memset faster than calloc?

623


What is actual argument?

598


What is the difference between strcpy() and memcpy() function in c programming?

631


How can I implement sets or arrays of bits?

611


How is a null pointer different from a dangling pointer?

563


The performance of an operation in several steps with each step using the output of the preceding step a) recursion b) search c) call by value d) call by reference

679