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 a pointer in c plus plus?
In which language linux is written?
What is the meaning of && in c?
What is use of pointer?
When should volatile modifier be used?
When can you use a pointer with a function?
What are the header files used in c language?
Can you write the algorithm for Queue?
What is the difference between constant pointer and constant variable?
What would the following code segment printint k = 8;docout << "k = " << k << " ";while k++ < 5; a) 13 b) 5 c) 8 d) pointers
Can a variable be both const and volatile?
Explain what are the __date__ and __time__ preprocessor commands?
Explain 'far' and 'near' pointers in c.
On most computers additional memory that is accessed through an adapter of feature card along with a device driver program. a) user memory b) conventional memory c) expandedmemory d) area
Write a program for finding factorial of a number.