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 back slash character constants or escape sequence charactersavailable in c?

686


What is #include in c?

600


Describe the difference between = and == symbols in c programming?

777


Which is better oop or procedural?

634


What is 2 d array in c?

558






Take an MxN matrice from user and then sum upper diagonal in a variable and lower diagonal in a separate variables. Print the result

1469


Explain the properties of union.

609


Why do we need volatile in c?

742


Explain what is the difference between a string copy (strcpy) and a memory copy (memcpy)? When should each be used?

603


Why string is used in c?

580


Under what circumstances does a name clash occur?

690


What is sizeof in c?

571


How do I get a null pointer in my programs?

620


What is typedf?

670


typedef struct{ char *; nodeptr next; } * nodeptr ; What does nodeptr stand for?

1074