0
IS POSSIBLE TO PRINT 1 TO 100 WITHOUT FOR LOOP
IN C LANGUAGE NOT USE FOR WHILE
5 Respuestas
+ 4
and you can just unroll the loop e.g. type out 100 print statements
+ 2
PARTH CHAUHAN
Yes, you can via following ways:
1> Using recursion
2> Using while/do while loop
3> Using goto
3rd point example:
```
int n = 1;
start:
if (n <= 100) {
printf("%d\n", n);
n++;
goto start;
}
```
+ 2
do/while example:
#include <stdio.h>
int main() {
int i = 1;
do { printf("%d\n", i++); } while(i<=100);
}
+ 1
recursion example:
#include <stdio.h>
void print_i(int i, int i2){
if(i > i2) return;
printf("%d\n", i++);
print_i(i, i2);
}
int main() {
print_i(1, 100);
}
0
#include <stdio.h>
#define ZERO(x) (x=0)
int main() {
int n = 1;
while(n) n<=100 ? printf("%d\n", n++) : ZERO(n);
}