Saved Bookmarks
| 1. |
Read the following C++ statements:int * p, a=5p=&a; (a) What is the speciality of the variable p? (b) What will be the content of p after the execution of the second statement? (c) How do the expressions *p+1 and* (p+1) differ? |
|
Answer» (a) p is special variable and it is called a pointer. (b) p contains the address of the variable a (c) #include<iostream> using namespace std; int main () { int *p,a=5; p=&a; cout<<*p+1<<endI; cout<<*(p+1); } Here p+1 returns (address of the variable a) +4(4 is the size of int data type in Geany C++). *(p+1) returns the content of this next address location. |
|