Programming with Passion

Make the best out of everything.

Tuesday, 14 February 2017

Print 1 to 100 in C++, without loop and recursion


Print 1 to 100 in C++, without loop and recursion


Following is a C++ program that prints 1 to 100 without loop and without recursion.

#include<iostream>
using namespace std;
class A
{
public:
    static int a;
    A()
    {  cout<<a++<<endl;  }
};
int A::a = 1;
int main()
{
    int N = 100;
    A obj[N];
    return 0;
}

No comments:

Post a Comment