1. #include<iostream.h> void Execute(int &x,int y=200) { int temp=x+y; x+=temp; if(y!=200) cout<<temp<<” “<<x<<” “<<y<<endl; } void main() { int a=50,b=20; Execute(b); cout<<a<<” “<<b<<endl; Execute(a,b); cout<<a<<” “<<b<<endl; } 3. #include<iostream.h> int max(int &x,int &y,int &z) { if(x>y &&y>z) { y++; z++; return x; } else if(y>x) return y; else return z; } void main() { int a=10,b=13,c=8; a=max(a,b,c); cout<<a<<b<<c<<endl; b=max(a,b,c); cout<<++a<<++b<<++c<<endl; } 5. #include<iostream.h> void Modify(int &a,int b=10) { if(b%10==0) a+=5; for(int i=5;i<=a;i++) cout<<b++<<”:”; cout<<endl; void Disp(int x) { if(x%3==0) Modify(x);

2. #include<iostream.h> int a=3; void demo(int x, int y,int &z) { a+=x+y; z=a+y; y+=x; cout<<x<<” “<<y<<” “<<z<<endl; } void main() { int a=2,b=5; demo(::a,a,b); cout<<::a<<” “<<a<<” “<<b<<endl; demo(::a,a,b); } 4.Write the output of the following program : #include<iostream.h> int calc(int u) { if(u%2==0) return u+10; else return u*2; } void pattern(char M, int B=2) { for(int cnt=0;cnt<b;cnt++) cout<<calc(cnt)<<m; cout<<endl; } void main() { pattern(‘*’); pattern(‘#’,4); pattern(‘@’,3); }
6. #include <iostream.h> int counter1(int m,int n = 1) { int r, s = 0; while( m != 0) { r = m % 10; r = r * n; s = s*10 + r; m = m / 10; } return s; } void main() { int data=1234; data = counter1(data);


else Modify(x,3); } void main() { Disp(3); Disp(4); Modify(2,20); 7. #include<iostream.h> int func (int &x, int y=10) { if(x%y==0) return ++x; else return y--; } void main()
{ int p=20,q=23; q=func(p,q); cout<<p<<” “<<q<<endl; p=func(q); cout<<p<<” ”<<q<<endl; q=func(p); cout<<p<<” “<<q<<endl; }

cout<<data<<endl; data = counter1(data,2); cout<<data<<endl; }

} 8. char *s=”GOODLUCK”; for(int x=strlen(s)-1;x>0;x--) { for(int y=0;y<=x;y++) cout<<s[y]; cout<<endl; }

9. Write a function in C++ which accepts a character array and its size as arguments and reverse that array without using second array and library function. Example : if the array is having: “Computer Science” Then after reversal it should rearranged as: “ecneicS retupmoC” 10.WAF that accept an array of 10 integers with size. The function fins a particular number from the array by using the binary search method 11.write a user define function repeat() which takes a two dimensional array with size N rows and M columns as argument and convert all repeated element into zero. 12.Write a user defined function in C++ to multiply 5 to each element of array X[4][4] except diagonal elements where array is passed as parameter. 13. Write a function in C++ to find and display the sum of each row and each column of a 2D array of type float. Use the array and its size as parameters with float as its return type. 14. Write a user defined function in C++ to display the multiplication of column elements of a 2 dimensional array MATRIX [6][6] containing integers 15. ) Write a user defined function in C++ to display those elements of 2 dimensional array T[4][4] which are divisible by 100. Assume the content of the array is already present and the function prototype as follows void Display(int T[4][4]); 16. Write a function in c++ which accepts a 2D array of integers, number of rows and number of columns as arguments and assign the elements which are divisible by 3 or 5 into a one dimensional array of integers.

If the 2D array is 12 3 9 14  24 25 16 31   19 32 45 27   11 5 28 18  The resultant 1D arrays is 12 , 3 , 9 , 24 , 25 , 45 , 9 , 5 , 18

Sign up to vote on this title
UsefulNot useful