Q.11
#include <iostream>
using namespace std;
int func(int x);
void main()
{
cout << func(0) << endl;
cout << func(1) << endl;
cout << func(2) << endl;
cout << func(5) << endl;
}
int func(int x)
{
if (x==0)
return 2;
else if (x==1)
return 3;
else
return (func(x-1) + func(x-2));
}
#include <iostream>
using namespace std;
int func(int x);
void main()
{
cout << func(0) << endl;
cout << func(1) << endl;
cout << func(2) << endl;
cout << func(5) << endl;
}
int func(int x)
{
if (x==0)
return 2;
else if (x==1)
return 3;
else
return (func(x-1) + func(x-2));
}
Output: