Forum

Number Of Page View:100,000+/Months
LOGIN |New User

Reply

How to print 1 to 100 without using any conditional loop?
There are 2 ways i have given you. Using these you can solve this problem.

1.Using Recursion:

DisplayInfo(Int num = 1)
{
   Printf("%d ", num);
   if(num == 100)
   return;
   else
   DisplayInfo(++num);
} 

2.

#include<stdio.h>
#include<conio.h>
void main()
{
   int n=1;
   clrscr();
   SHOW:
   if(n>100)
{
}
   else
{
   printf("%d ",n);
   n+=2;
   goto SHOW;
}
getch();
}