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

What are the two forms of #include directive?

848


What is data structure in c language?

831


Give a one-line C expression to test whether a number is a power of 2. [No loops allowed - it's a simple test.]

823


cavium networks written test pattern ..

3798


i have to apply for rbi before that i need to know the the syllabus for the entrance questions. whethet it may be aps or techinical

2071


What is the difference between volatile and const volatile?

743


How can I trap or ignore keyboard interrupts like control-c?

806


What is #define?

778


please explain every phase in the "SDLC" in the dotnet.

2377


What does 3 mean in texting?

809


what are non standard function in c

1632


What is p in text message?

724


Explain what is the concatenation operator?

821


A function can make the value of a variable available to another by a) declaring the variable as global variable b) Passing the variable as a parameter to the second function c) Either of the two methods in (A) and (B) d) binary stream

913


What is c definition?

951