How to print 1 to 100 without using any conditional loop?

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
#include
void main()
{
   int n=1;
   clrscr();
   SHOW:
   if(n>100)
{
}
   else
{
   printf("%d ",n);
   n+=2;
   goto SHOW;
}
getch();
} 

By:Vivek kr. Agarwal
Date:2031-12-08 00:00:00

 i don't know whether it will or not
#include
#include
void aa(int);
void main()
{
int a=1;
aa(a);
getch();
}
void aa(int a)
{
printf("%d",a)
a++;
aa(a<=100);
}


By:kavin
Date:2009-12-10 00:00:00

Post Your Answers


User Email:

User Name:
Answers:

Related C Subjective Links

C Subjective interview questions and answers for experienced and fresher