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

hi, which software companys will take,if d candidate's % is jst 55%?

0 Answers  


What is non linear data structure in c?

0 Answers  


Explain pointer. What are function pointers in C?

0 Answers   HCL,


what does ‘#include’ mean?

1 Answers   TCS,


Write a program which has the following seven functions. The functions should be: • main() this calls the other 6 functions • fget_long() a function which returns a long data type from a file • fget_short() a function which returns a short integer variable from a file • fget_float() a function which returns a floating point variable from a file • fprt_long() a function which prints its single, long argument into a file • fprt_short() a function which prints its single, short argument into a file • fprt_float() a function which prints its single, floating point argument into a file. You should use fscanf() to get the values of the variables from the input (the file) and fprintf() to print the values to the other file. Pay attention to using the correct format for each of the data types.

0 Answers  


If null and 0 are equivalent as null pointer constants, which should I use?

0 Answers  


In how much time you will write this c program? Prime nos from 1 to 1000

2 Answers   TCS,


How are pointers declared in c?

0 Answers  


Why data types in all programming languages have some range? Why ritche have disigned first time likethat?Why not a single data type can support all other types?

2 Answers   Excel,


Is a house a mass structure?

0 Answers  


What is the difference between scanf and fscanf?

0 Answers  


Write a program to replace n bits from the position p of the bit representation of an inputted character x with the one's complement. Method invertBit takes 3 parameters x as input character, p as position and n as the number of positions from p. Replace n bits from pth position in 8 bit character x. Then return the characters by inverting the bits.

0 Answers   Infosys,


Categories