0% found this document useful (0 votes)
20 views1 page

Class XII ISC Computer Science Recursion Output Paper

The document contains a series of program segments related to recursion in computer science, specifically designed for Class XII ISC students. Each segment includes a function that demonstrates different recursive concepts, with the expected output indicated for each. The exercises aim to enhance students' understanding of recursion through practical coding examples.

Uploaded by

gwinshaurya
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views1 page

Class XII ISC Computer Science Recursion Output Paper

The document contains a series of program segments related to recursion in computer science, specifically designed for Class XII ISC students. Each segment includes a function that demonstrates different recursive concepts, with the expected output indicated for each. The exercises aim to enhance students' understanding of recursion through practical coding examples.

Uploaded by

gwinshaurya
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

SUNSHINE PUBLIC SCHOOL Class XII ISC – Computer Science

Topic: Recursion (Output Based Questions)


Predict the output of the given program segments.
1. void test(int n) 2. int sum(int n) 3. void display(int n)
{ { {
if(n>0) if(n==0) if(n==0)
{ return 0; return;
[Link](n+" "); return n+sum(n-1); display(n-1);
test(n-1); } [Link](n+" ");
} } test(4); [Link](sum(5)); } display(3);
4. int fun(int x) 5. void show(int n) 6. int calc(int a,int b)
{ { {
if(x==1) if(n<1) if(b==0)
return 1; return; return 1;
return x*fun(x-1); [Link](n); return a*calc(a,b-1);
} [Link](fun(4)); show(n-2); }
} show(7); [Link](calc(2,3));
7. void print(int n) 8. int f(int n) 9. void test(int n)
{ { {
if(n>0) if(n<=1) if(n==0)
{ return n; return;
print(n-1); return f(n-1)+f(n-2); [Link](n%2);
[Link](n); } test(n/2);
print(n-1); [Link](f(5)); } test(6);
}} print(2);
10. int count(int n) 11. void fun(int n) 12. int series(int n)
{ { {
if(n==0) if(n<10) if(n==1)
return 0; [Link](n); return 2;
return 1+count(n/10); else return series(n-1)+3;
} { }
[Link](count(2456)); fun(n/10); [Link](series(4));
[Link](n%10);
} } fun(358);
13. void test(int n) 14. int fun(int n) 15. void display(int n)
{ if(n==0) { {
return; test(n-1); if(n<=0) if(n>0)
[Link](n*n+" "); return 0; {
} return fun(n-2)+n; [Link](n+" ");
test(3); } display(n/2);
[Link](fun(6)); }}
display(10);
16. int mystery(int n) 17. int compute(int n) 18. void print(int n)
{ if(n==0) { {
return 0; if(n==1) if(n==0)
return (n%10)+mystery(n/10); return 1; return 1;
} return compute(n-1)*2; [Link](n+" ");
[Link](mystery(123)); } print(n-1);
[Link](compute(5)); [Link](n+" ");
} print(3);
19. int func(int n)
{
if(n==0)
return 1;
return func(n-1)+n;
}
[Link](func(4));

You might also like