Q.10:
#include <iostream>
using namespace std;
int test(int x, int y);
int main()
{
cout << test (5,10) << endl;
cout << test (3,9) << endl;
}
int test(int x, int y)
{
if (x==y)
return x;
else if (x>y)
return (x+y);
else
return test(x+1,y-1);
}
Output:
a. 15
b. 6
No comments:
Post a Comment