14 Nov 2019

  • November 14, 2019
  • Amitraj
Print all natural numbers upto N without using semi-colon.

We use the idea of recursively calling main function.

// CPP program to print all natural numbers upto 
// N without using semi-colon 

#include<iostream>
using namespace std;
int N = 10;

int main()
{
static int x = 1;
if (cout << x << " " && x++ < N && main())
{ }
return 0;
}

OUTPUT:

1 2 3 4 5 6 7 8 9 10


Translate

Popular Posts