c program to print n numbers without using loop
>> Tuesday, November 1, 2011
This program will print the n numbers without using any loop. Here we uses the concept of recursion. Lets See the program
to make clear view that how recursion works.
#include <stdio.h>
#include <conio.h>
void print(int p)
{
if(p>0)
{
print(p-1); // recursive call;
printf("\n\n %d \t", p);
}
return;
}
int main()
{
int n;
printf("enter the number\n\n");
scanf("%d",&n); // number to which you wnat to print
print(n);
getch();
return 0;
}
Output:
0 comments:
Post a Comment