Write a C program to print 1 2 3 ... 100 without using
loops?

Answers were Sorted based on User's Feedback



Write a C program to print 1 2 3 ... 100 without using loops?..

Answer / sutanu

void main ()
{
static int i;
if (i <= 100)
{
printf ("%d\n", i);
i++;
main ();
}
}

Is This Answer Correct ?    53 Yes 15 No

Write a C program to print 1 2 3 ... 100 without using loops?..

Answer / gunabalan

void main()
{
int i=1;
e:
printf("%d\t",i);
i++;
if(i<=100)
goto e;
}

Is This Answer Correct ?    36 Yes 12 No

Write a C program to print 1 2 3 ... 100 without using loops?..

Answer / lakshmipraba

#include<stdio.h>
int i;
void main()
{
if(i<=100)
{
printf("%d ",i);
i++;
main();
}
if(i>100)
exit(0);
}

Is This Answer Correct ?    14 Yes 3 No

Write a C program to print 1 2 3 ... 100 without using loops?..

Answer / vivek

void main()
{
int i=1;
if(i<=100)
printf("%d",i);
continue;
getch();
}

Is This Answer Correct ?    6 Yes 2 No

Write a C program to print 1 2 3 ... 100 without using loops?..

Answer / neha

int i;
void main(void)
{
if(i<=100)
printf("%d\n", i);
i++;
main();
getch();
}

Is This Answer Correct ?    29 Yes 26 No

Write a C program to print 1 2 3 ... 100 without using loops?..

Answer / uma maheswari

#include<stdio.h>
#include<conio.h>
int i=1;
void main()
{
i<=100 ? printf("%d\n",i) : getch(); //conditional operator
i++;
main(); //recursive calling of main() function
}

Is This Answer Correct ?    10 Yes 7 No

Write a C program to print 1 2 3 ... 100 without using loops?..

Answer / sagar

we can also create such a program without using loops and if
statement too ...

void main()
{
int i,n;
clrscr();
A:
printf("%d",i);
n=i++;
switch(n)
{
case 100: break;
default : goto A;
}
getch();
}

Is This Answer Correct ?    9 Yes 7 No

Write a C program to print 1 2 3 ... 100 without using loops?..

Answer / harsha

#include<stdio.h>

int i=0;

void main()
{
if(i==0)
clrscr();
if(i<100) {
printf("%d \t",++i);
main(); }
else {
getch();
exit(0); }
}

Is This Answer Correct ?    2 Yes 1 No

Write a C program to print 1 2 3 ... 100 without using loops?..

Answer / maxerp

In general, by using recursion, since it is the only
alternative to looping constructs

Is This Answer Correct ?    11 Yes 12 No

Write a C program to print 1 2 3 ... 100 without using loops?..

Answer / vivek

#include<stdio>
void main()
{
int i=1;
if(i<=100)
printf("%d",i);
i++;
continue;
getch;
}

Is This Answer Correct ?    2 Yes 3 No

Post New Answer

More C Interview Questions

Which is the best website to learn c programming?

0 Answers  


What is meant by global static? why we have to use static variable instead of Global variable

4 Answers   L&T,


HOW TO HANDLE EXCEPTIONS IN C

8 Answers  


let's take a code struct FAQ { int a; char b; float c; double d; int a[10]; }*temp; now explain me how the memory will be allocated for the structure FAQ and what address will be in the structure pointer (temp)....................

8 Answers  


State two uses of pointers in C?

0 Answers   Aspire, Infogain,






What is the difference between constant pointer and constant variable?

0 Answers   NIIT,


write a c program to add two integer numbers without using arithmetic operator +

13 Answers   Value Labs,


What is a node in c?

0 Answers  


What is Bitwise Operator and how it works?

1 Answers  


exit () is used to a) exit () terminates the execution of the program itself b) exit () terminates the execution of the loop c) exit () terminates the execution of the block d) none of the above

0 Answers  


What is meant by realloc()?

0 Answers  


Can the size of an array be declared at runtime?

0 Answers  


Categories