C program to Print Numbers from 1 to 10 without using Loop


Here this problem is solved by a recursive function. I initialized some value into display(value) function and this function will call again by again until given condition is not false. For understanding read this program. Here I suggest you if you are not familiar with recursive function then first go study about recursive function.

How To print numbers from 1 to 10 without using loop

#include<stdio.h> void display(int n) { if(n > 0) { display(n-1); printf("%d ", n); } return; } int main() { display(100); return 0; }

Output:-

1 2 3 4 5 6 7 8 9 10

Explanation of Program :

In this program, we call display() function and this will call again by again until the condition is not false. You can deeply understand by given below descriptions.
display(10)
void display(int n)
Now here,
If ( n > 0 ) then
display(n-1)
It will continuously play until condition false.
Value will print 1 2 3 4 5 6 7 8 9 10