Sie sind auf Seite 1von 3

Assignment 7 Class XI(Computer Science C++) ( Functions) Q1. Q2. Q3. Q4.

What are the three steps in using a function? How is function declaration different from function definition? What is another name of function prototype? Construct function prototype for description given below: a. Display() takes no arguments and has no return vale b. Count() takes a float argument and return a n integer value c. San() takes two double arguments and return a double d. Check() takes a string argument and return an int e. Len() takes an integer array, int value as argument and return a long result What is the condition of using a function in an expression? What are actual and formal parameters of a function? What are global and local prototypes? When can a function prototype be omitted? When is a default argument value used inside a function? What is the principal reason for passing argument by value? What is the principal reason for passing argument by reference? What re the three types of function in C++? How is call; by value is different from call by reference? Give appropriate example supporting your answer? Identify the errors in the following function prototype? a. float aveg(a,b); b. float(int m,n); c. float(int m ; int n); d. void display(int a[],s=10); e. void A1(int a[],int b[],int s=10,int j); f. float d1(int,int,float=3.14);

Q5. Q6. Q7. Q8. Q9. Q10. Q11. Q12. Q13. Q14.

Q15. Give the output of the following program code. Justify your answer: #include<iostream.h> Int m=5; void main() { int m=30; { int m=20*::m; cout<<m=<<m<<\t<<::m =<<::m; } cout<<m=<<m<<\t<<::m =<<::m; } Q16. Identify the problem with following code: void larg(int &m , int &n); { if(m>n) m=-1;

else n=-1 } void main( ) { larg(5,7); } Q17. In the following program, find the correct possible output(s) from the options. Justify your answer. (A) #include<iostream.h> #include<stdlib.h> void main( ) { randomized( ); char City[5][10]={DEL, CHN, KOL, BOM, BNG}; int fly; for(int i=0;i<3;i++) { fly=random(2)+I; cout<<City[fly]<<\t; } } (B)#include<iostream.h> #include<stdlib.h> void main( ) { randomized( ); for(int i=0;i<3;i++) { p=random(i)+4; cout<<p<<\t; } } Q18. In the following program, find the incorrect output(s) from the options. Justify your answer. #include<iostream.h> #include<stdlib.h> void main( ) { int n [ ]={1, 4, 7, 9, 12, 20}; int r, m[6]; randomized( ); for(int i=0;n[i]<20;i++) m[i]=n[i]+4;

for(i=1;i<4;i++) { r=random(i); cout<<m[r]<<#; } } Options: (1) 5#5#5# (3)13#16#24# Q19.

(2) 5#13#16# (4)5#8#11#

Q20.

Give the output of the following program code: int g=10; void code(int x, int y=5) { ::g+=25; x-=y; y*=10; cout<<x<<\t<<y<<\n; } void main ( ) { int g=7; code(g); cout<<g<<\t<<::g; } Give the output of the following program code: void encode(int &x, int y=25) { if(y!=25) x = x+y*y; else y = y+x*x; cout<<x<<\t<<y<<\n; } void main ( ) { int a,b; a = 5; b = 6; encode(a); cout<<a<<\t<<b<<\n; encode(a,b); cout<<a<<\t<<b<<\n; }

Das könnte Ihnen auch gefallen