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
What is 1f in c?
what are bit fields in c?
Why do we use c for the speed of light?
What are keywords in c with examples?
What is I ++ in c programming?
What is the use of typedef in structure in c?
What is the general form of #line preprocessor?
What does typedef struct mean?
Explain how can I make sure that my program is the only one accessing a file?
What is the right type to use for boolean values in c? Is there a standard type? Should I use #defines or enums for the true and false values?
How can I remove the trailing spaces from a string?
What is a pointer in c?
What is the difference between class and object in c?
What is a stream in c programming?
What is the value of a[3] if integer a[] = {5,4,3,2,1}?