+ 2
Print numbers 1 toN without using semicolon and loop ?
#include<stdio.h> #define N 10 int main(int num) { if(num<=N&&printf("%d",num)&&main(num+1)) }
1 Answer
+ 1
I honestly don't know if it can be done without semicolons, but here's one with no loops in case it helps you:
#include <stdio.h>
#define N 10
int num=1;
int main() {
if (num<=N){
printf("%d ",num);
num++;
main();
}
return 0;
}