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 are the back slash character constants or escape sequence charactersavailable in c?
What is #include in c?
Describe the difference between = and == symbols in c programming?
Which is better oop or procedural?
What is 2 d array in c?
Take an MxN matrice from user and then sum upper diagonal in a variable and lower diagonal in a separate variables. Print the result
Explain the properties of union.
Why do we need volatile in c?
Explain what is the difference between a string copy (strcpy) and a memory copy (memcpy)? When should each be used?
Why string is used in c?
Under what circumstances does a name clash occur?
What is sizeof in c?
How do I get a null pointer in my programs?
What is typedf?
typedef struct{ char *; nodeptr next; } * nodeptr ; What does nodeptr stand for?