I was trying to do some simple exercises on recursive functions:
1. Write a function using Recursion to print numbers from n to 0.
My solution:
int integer(int n)
{
if(n>=0)
{
printf("\n%d",n);
integer(--n);
}
}
The next exercise was
2. Write a function using Recursion to print numbers from 0 to n. (You just need to shift one line in the program of problem 1.)
Well i dont know how to do it using recursion; at least not by shifting just one line of the previous code. And also did not want to use any other variables.
Is there any simple solution to the 2nd problem. Help me out?