You are on page 1of 4

Assignment of Functions Class XI Q1. Rewrite the following program after removing the syntactical error(s) if any.

Underline each correction. #include<iostream.h> #include<iostream.h> void main( ) void ,ithdef(int -is*um".#) !irst " 1#$ %econd " &#' (umpto(!irst'%econd)' (umpto(%econd)' ) void (umpto(int *1$ int *& " &#) *1"*1+*&' count<<*1>>*&' ) for(int /"&#'/<"-is*um'/+"0) cout<</<<.$.' cout<<endl' ) void 1ontrol(int 23y*um) 3y*um+"1#' ,ithdef(3y*um)' ) void main() int 4our*um"&#' 1ontrol(4our*um)' ,ithdef()' cout<<.*um5er".<<4our*um<<endl' ) #include<iostream.h> void main( ) int :' cin>>:' for( int y"#$y<1#$y++) cout<<:+y' )

#include<iostream.h> const int 3ultiple .' void main( ) value " 10' for(int 1ounter " 1'1ounter " <0'1ounter ++$ 6alue 7" &) if(6alue83ultiple " " #) cout<<6alue 9 3ultiple' cout<<end1' else cout<<6alue + 3ultiple <<endl' )

#include ;iostream.h< void main >ssign(past)' ) 6oid >ssign ( int default1 $default&".#)' default1"default1+ default&' cout<<default1>> default&' ) =resent"&0$ past".0' >ssign(present ' past)'

#include ?iostream.h@ void main() int i"1 ':"&#$a"#$5"1$c' cout>>a>>@$@>>5' do c"a+5' a"5' 5"c' cout>>@$@>>c' i++' )while(i<":) )

Q&. !ind the output of the following programA #include<iostream.h> void main( ) int U"1#$6"&#' for(int /"1'/<"&'/++) cout<<@;1<@<<U++<<@2@<<69 0 <<endl' cout<<@;&<@<<++6<<@2@<<U + & <<endl' ) ) #include<iostream.h> void main( ) Bong *U3"1&.C0C.' int !"#$%"#' do int R"*U3 8 1#' if (R 8& D" #) ! +" R' else % +" R' *U3 E " 1#' ) while (*U3>#)' cout<<!7%' ) #include<iostream.h> int H:ecute(int 3) if(38.""#) return 39.' else return 3+1#' ) void Iutput(int J"&) for(int F"#'F<J'F++) cout<<H:ecute(F)<<@9@' cout<<endl' ) void main( ) Iutput(C)' Iutput( )' Iutput(.)' ) #include<iostream.h> void H:ecute(int 2K$int 4"&##) int FH3="K+4' K+"FH3=' if(4D"&##) cout<<FH3=<<K<<4<<endl' ) void main( ) int >"0#$J"&#' H:ecute(J)' cout<<><<J<<endl' H:ecute(>$J)' cout<<><<J<<endl' )

#include<iostream.h> void /ndirect(int Femp"&#) for(int /"1#'/<"Femp'/+"0) cout<</<<@$@' cout<<endl' ) void Girect(int 2*um) *um+"1#' /ndirect(*um)' ) void main( ) int *um5er"&#' Girect(*um5er)' /ndirect( )' cout<<.*um5er ".<<*um5er<<endl' ) void main( ) int :"0$y"0' cout<<:7 7' cout<<@$@' cout<7 7 :' cout<<@$@' cout<<y7 7<<@$@<<7 7y' )

#include<iostream.h> #include<conio.h> int g"&#' void func(int 2:$int y) :":7y' y":91#' cout<<:<<.$.<<y<<.Ln.' ) void main( ) int g"M' func(g$AAg)' cout<<g<<.$.<<AAg<<.Ln.' func(AAg$g)' cout<<g<<.$.<<AAg<<.Ln.' ) #include<iostream.h> int 2ma: (int 2:$int 2y) if(:>y) return (:)' else return (y)' ) void main() int >"1#$J"1.' ma:(>$J)"71' cout<<@>" ?<<><<@J" ?<<J<<endl' ma:(J$>)"M' cout<<@>" ?<<><<@J" ?<<J<<endl' ) void H:ecute(int 2:$int y"&##) int temp":+y' :+"temp' if(yD"&##) cout<<temp<<@ ?<<:<<@ ?<<y<<endl' ) void main() int a"0#$5"&#' H:ecute(5)' cout<<a<<@ ?<<5<<endl' H:ecute(a$5)' cout<<a<<@ ?<<5<<endl' )

#include<iostream.h> int func(int 2:$int y"1#) if(:8y""#) return ++:'else return y7 7' ) void main( ) int p"&#$N"&.' N"func(p$N)' cout<<p<<N<<endl' p"func(N)' cout<<p<<N<<endl' N"func(p)' cout<<p<<N<<endl' )

#include<iostream.h> int a"1#' void main() void demo(int 2$int$int 2)' int a"&#$5"0' demo(AAa$a$ 5)' cout<<AAa<<a<<5<<endl' ) void demo(int 2:$int y$int 2O) a+":' y9"a' O"a+y' cout<<:<<y<<O<<endl' ) #include<iostream.h> int ma:(int 2:$int 2y$int 2O) if(:>y 22y>O) y++' O++' return :' ) else if(y>:) return y' else return O' ) void main() int a"1#$5"1.$c"P' a"ma:(a$5$c)' cout<<a<<5<<c<<endl' 5"ma:(a$5$c)' cout<<++a<<<++5<<++c<<endl' )

Q1 a. ,rite a 1++ function having two value parameters K and * with result type float to find the sum of series given 5elowA S=1 + x1/2! + x2/3! + x3/4! + x4/5! + - - - - - - xn/ n+1!! "# ,rite a UG! having one value parameters * with result type long to find the sum of series given 5elowA 1Q+.Q+0Q+MQRRR n terms c. ,rite a UG! having two value parameters K and * with result type float to find the sum of series given 5elowA a. 1 7 :QE&D + :SCECD 7 :STETD + ....... :SnEnD d. ,rite a 1++ function having two value parameters K and * with result type float to find the sum of series given 5elowA S=1 + x1/2! - x2/3! + x3/4! -x4/5! + - - - - - - xn/ n+1!! e# ,rite a 1++ function having one value parameter * with result type long to find factorial of a given num5er. f. ,rite a 1++ function having two value parameters K and * with result type Bong to return power of K and if * is not passed then the function should return sNuare of K QC /dentify Ulo5al and local varia5leA #include <iostream.h> float *U3"V##' void BI1>B(int F) int Fotal"#' for (int /"#'/<F'/++) Fotal+"/' cout<<*U3+Fotal' ) void main() float *U3' *U3"&#' BI1>B(*U3)' ) Q0. Gifferentiate 5etweenA 1all 5y value and call 5e reference >ctual parameter and formal parameter

You might also like