You are on page 1of 3

MAHARAJA AGRASEN MODEL SCHOOL,CD BLOCK, PITAM PURA, DELHI.

CLASS XI
ASSIGNMENT – FUNCTIONS,2D ARRAY

Output Questions:
1. #include<iostream.h> 2. #include<iostream.h>
void Execute(int &x,int y=200) int a=3;
{ int temp=x+y; x+=temp; void demo(int x, int y,int &z)
if(y!=200) { a+=x+y;
cout<<temp<<” “<<x<<” “<<y<<endl; z=a+y;
} y+=x;
void main() cout<<x<<” “<<y<<” “<<z<<endl; }
{ int a=50,b=20; void main()
Execute(b); { int a=2,b=5;
cout<<a<<” “<<b<<endl; demo(::a,a,b);
Execute(a,b); cout<<::a<<” “<<a<<” “<<b<<endl;
cout<<a<<” “<<b<<endl; } demo(::a,a,b); }

3. #include<iostream.h> 4.Write the output of the following


int max(int &x,int &y,int &z) program :
{ if(x>y &&y>z) #include<iostream.h>
{ y++; int calc(int u)
z++; { if(u%2==0)
return x; } return u+10;
else else
if(y>x) return u*2;
return y; }
else void pattern(char M, int B=2)
return z; { for(int cnt=0;cnt<b;cnt++)
} cout<<calc(cnt)<<m;
void main() cout<<endl;
{ int a=10,b=13,c=8; }
a=max(a,b,c); void main()
cout<<a<<b<<c<<endl; { pattern(‘*’);
b=max(a,b,c); pattern(‘#’,4);
cout<<++a<<++b<<++c<<endl; pattern(‘@’,3); }
}

5. #include<iostream.h> 6. #include <iostream.h>


void Modify(int &a,int b=10) int counter1(int m,int n = 1)
{ { int r, s = 0;
if(b%10==0) while( m != 0)
a+=5; { r = m % 10;
for(int i=5;i<=a;i++) r = r * n; s = s*10 + r;
cout<<b++<<”:”; cout<<endl; } m = m / 10; }
void Disp(int x)
return s; }
{
void main()
if(x%3==0)
Modify(x); {
else int data=1234;
Modify(x,3); } data = counter1(data);
void main() cout<<data<<endl;
{ data = counter1(data,2);
Disp(3); cout<<data<<endl;
Disp(4); Modify(2,20); } }

7. #include<iostream.h> 8. char *s=”GOODLUCK”;


int func (int &x, int y=10) for(int x=strlen(s)-1;x>0;x--)
{ {
if(x%y==0) return ++x; else return y--; for(int y=0;y<=x;y++)
} cout<<s[y];
void main() cout<<endl;
{ 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;
}

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.
12 3 9 14

If the 2D array is
[ 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

You might also like