Q7:
#include <iostream>
using namespace std;
int mystery(int number);
int main()
{
while (1)
{
int x;
cout << "x: ";
cin >> x;
cout << mystery(x) << endl << endl;
}
}
int mystery(int number)
{
if (number == 0)
return number;
else
return (number + mystery(number-1));
}
Output:
No comments:
Post a Comment