22. Give the output of the following: Pointer prg1.cpp #include <iostream.h> #include <conio.h> void main() { clrscr(); int * ptr; int i=25; ptr=&i; cout<<i<<‘’; cout<<&i<<‘’; cout<<ptr<<‘’; cout<<* ptr <<‘’; cout<< <*<*(& i)<<‘’; }
23. Give the output of the following: Pointer prg2.cpp #include <iostream.h> #include <conio.h> void main() { clrscr(); char * cp; char ch=‘a’; cp=& ch; cout<<* ptr <<‘’; cout<< <*<*(& i)<<‘’; }
24. Give the output of the following: Pointer prg3.cpp #include <iostream.h> #include <conio.h> void main() { clrscr(); char *p1,*p2,*p3; int x=5; int y=7; p1=&x; p2=&y; cout << “original values are : “;<<*p1<<*p2; p3=p1; p1=p2; p2=p3; cout << “exchanged values are : “;<<*p1<<*p2; getch(); }
25.
26. So, if we write: Assume following pointers: int *iptr;// //assume it points to location 1000 char *cptr; //assume it points to location 2000 float *fptr; //assume it points to location 3000 iptr++; //iptr will be incremented by 2 cptr++; //cptr will be incremented by 1 fptr++; //fptr will be incremented by 4
27. n Heap memory iptr 1000 1002 int *iptr;// //assume it points to location 1000 n Heap memory iptr 1000 1002 iptr++; //iptr will be incremented by 2