GeeksforGeeks Solution For School Domain .Below You Can Find The Solution Of Basic ,Easy ,Medium ,Hard .You Can Also Direct Submit Your Solution to Geeksforgeeks Same Problem .You Need to login then you can submit you answers
Problem :- Print numbers from 1 to n without the help of loops.
Submit Your Solution :- Click Here
Solution :-
#include<stdio.h>
void f(int n){
static int i=1;
if(i>n){
i=1;
return;
}
printf("%d ",i);
i+=1;
f(n);
}
int main()
{
int t,lim;
scanf("%d",&t);
while(t--)
{
scanf("%d",&lim);
f(lim);
printf("\n");
}
}
Output:-
0 Comments: