Can't Get My C++ Program to Countdown (Recursive Function)?

Shawn

New member
I know that this is probably simple, and it was working correctly and then I fixed something else, specifically the aspect of the code that closes as it approaches '0'. This is the code I have so far, any help is appreciated! Thanks!

#include <iostream>

using namespace std;

void countDown(int x)
{
if(x != 0)
{
countDown(x - 1);
cout << x << " ";
return;
}


}

int main()
{
int num;
cout << "Enter a positive number: ";
cin >> num;
countDown(num);
}
Also, this is an assignment and I'm not allowed to mess at all with anything else besides what's under 'void countDown'.
 
Back
Top