asspoi.doc
DESCRIPTION
assignment pointerTRANSCRIPT
![Page 1: Asspoi.doc](https://reader036.vdocuments.us/reader036/viewer/2022083018/577c7c2b1a28abe0549991ff/html5/thumbnails/1.jpg)
CBS:PV:XII:ASSIGNMENT – 5 : POINTERS
1. What is a pointer? What are the arithmetic operations, one can perform on a pointer variable? Explain using suitable examples.
2. How will you declare and initialize a pointer? Give suitable example.3. What do you understand by dynamic memory allocation/deallocation? What are the
merits and demerits of static and dynamic memory allocation?4. Define variable, array and pointer.5. Explain reference variables and use of alias with some suitable examples.6. What do you understand by function returning a pointer? Give suitable example in
support of your answer.7. Explain the function call by reference giving a suitable example in support of your
answer.8. How can you access the members of a s structure using a pointer variable pointing to that
structure?9. What is the utility of dereference operators? Explain using suitable examples.10. What are self referencial structures? Explain by giving suitable example.11. What is the difference between pointers to constants and constant pointer? Give
examples.12. iiustrate the use of this pointer with the help of an example.13. Write a C++ program to find the largest element in an array using pointers?14. Write a C++ program to accept a string and check if it is a palindrome using pointers.15. Write a C++ program to accept a string and a character and print the number of times the
character has occurred in the string using pointers.16. What do you mean by memory leaks? What are the possible reasons for it? How it can be
avoided?17. A C++ program contains the following declaration:
static int x[8]={10,20,30,40,50,60,70,80};i) What is the meaning of x?ii) What is the meaning of (x+2)?iii) What is the value of *x?iv) What is the value of (*x+2)?v) What is the value of *(x+2)?
18. Give the output of the following:#include<iostream.h>#include<string.h>class per{ char name[20]; float age; public: per(char *s,float a) { strcpy(name,s);age=a;} per *gr(per &x) { if(x.age>=age) return x; else return *this;}
![Page 2: Asspoi.doc](https://reader036.vdocuments.us/reader036/viewer/2022083018/577c7c2b1a28abe0549991ff/html5/thumbnails/2.jpg)
void display(){ cout<< “Name :”<<name<<’\n’; cout<< “Age :” <<age<<’\n’;}};void main(){per p1(“RAMU”,27.5),p2(“RAJU”,53),p3(“KALU”,40);per p(‘\0’,0);p=p1.gr(p3);p.display();p=p2.gr(p3);p.display();}
19. Give the output : #include<iostream.h> #include<conio.h> int a=10; void main() { void demo(int &,int, int *); clrscr(); int a=20,b=5; demo(::a,a,&b); cout<<::a<< ‘\t’<<a<< ‘\t’<<b<<endl; } void demo(int &x, int y,int *x) { a+=x;y*=a;*z=a+y; cout<<x<< ‘\t’<<y<< ‘\t’<<*z<<endl; 20. Give the output:
i)char *s= “GOODLUCK”;for(int x=strlen(s)-1;x>=0;x--){ for(int y=0;y<=x;y++) cout<<s[y]; cout<<endl;}ii)void main(){ int a=32,*x=&a; char ch=65, &cho=ch; cho+=a; *x+=ch; cout<<a<< ‘,’<<ch<<endl;}
*******************