+ 1

Print all natural numbers upto N without using semi-colon.

We use the idea of recursively calling main function.

16th May 2018, 5:31 PM
Kavina
Kavina - avatar
4 odpowiedzi
+ 2
code??
16th May 2018, 5:37 PM
Bebida Roja
Bebida Roja - avatar
+ 2
// A recursive C program to print all numbers from 1 // to N without semicoolon #include<stdio.h> #define N 10 int main(int num) {  if (num <= N && printf("%d ", num) && main(num + 1))   { }    }
17th May 2018, 3:52 AM
Kavina
Kavina - avatar
+ 1
//with N default as 10 #include <iostream> int fn(int i, int x) { while(i<=x && std::cout<<i<<std::endl && i++ ){} } int main(int i, char **c){ if( ( i && i > 1 && fn(1,i)) || (i==1 && main(10, c))) {} }
16th May 2018, 7:09 PM
ifl
ifl - avatar
0
see this example in the playground https://code.sololearn.com/cHSOOwfG7RD7/?ref=app
16th May 2018, 8:56 PM
ifl
ifl - avatar