Write Chapter 17 5

Write Chapter 17 5
If you want to Find 5th Question of chapter 17

Search this Book

Friday 8 February 2013

Recursion Chapter 17 > Q.9

Q.9
#include <iostream>
using namespace std;

void exercise(int x);

int main()
{
while (1)
{
int x;
cout << "x: ";
cin >> x;

exercise(x);
cout << endl << endl;
}
}

void exercise(int x)
{
if (x>0 && x<10)
{
cout << x << " ";
exercise(x+1);
}
}


Output:



No comments:

Post a Comment