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
Explain union.
What is difference between arrays and pointers?
How do you do dynamic memory allocation in C applications?
Why should I use standard library functions instead of writing my own?
What is a structure and why it is used?
What is pragma in c?
What are the different data types in C?
how many types of operators are include in c language a) 4 b) 6 c) 8 d) 12
Write program to remove duplicate in an array?
Should I learn c before c++?
What are preprocessor directives in c?
How do you declare a variable that will hold string values?
What are the benefits of organizational structure?
How to implement a packet in C
Explain which of the following operators is incorrect and why? ( >=, <=, <>, ==)