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
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
Why is c so important?
How can I swap two values without using a temporary?
How does normalization of huge pointer works?
How can I recover the file name given an open stream?
Write a program that accept anumber in words
List the different types of c tokens?
What is union and structure in c?
How can you find out how much memory is available?
Is malloc memset faster than calloc?
What is actual argument?
What is the difference between strcpy() and memcpy() function in c programming?
How can I implement sets or arrays of bits?
How is a null pointer different from a dangling pointer?
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