c program to print n numbers without using loop. This c program will
print the n numbers without using any loop. Here we uses the concept of
recursion. You can see another program to print prime number using
recursion for refreshing recursion concept. Lets See the program to make
clear view that how recursion works.
c program to print n numbers without using loop:
#include <stdio.h>
#include <conio.h>
void print(int p)
{
if(p>0)
{
print(p-1); printf("\n\n %d \t", p);
}
return;
}
int main()
{
int n;
printf("enter the number\n\n");
scanf("%d",&n); print(n);
getch();
return 0;
}
Output of c program to print n numbers without using loop:
No comments:
Post a Comment