print numbers up n down

[output]i get errors... i need this to print numbers upwards from the number entered also print downwards

void printDown(int y)//print numbers down ward
{
if (y==0)
return;
cout<<y<<endl;
printDown(y-1);
return;
}
void printUp(inty)//print numbers upward
{
if (y==0)
return;
printUp(y-1);
cout<<y<<endl;
return;
}
int main()
{ int a,b;
cout<< "Enter any positive number" << endl;
cin>>x;
cout<<x<<"!"<<" = "<<factorial(x)<<endl;
cout<<"Enter number to count down from"<<endl;
cin>>a;
printDown(a);
cout<<"Enter number to count up from"<<endl;
cin>>b;
printUp(b);
return 0;
}
Hey, Ludidi

So, I didn't really see any problems other then you would want to have a space between int y on line in your printUp function's prototype.


other then that, you would need to write a simple function for the factorial function. and declare x in main ^_^.

for the most part it should work.

if that's not what you are asking, please tell me the output errors you are getting.


thanx so much
Topic archived. No new replies allowed.