It should be obvious by now that this exercise requires SOME type of looping. Recursion is just a different way of looping.

Whether the looping works with the program code, (in whatever logic), the operating system, or even the underlying hardware, it makes no difference in terms of the logic. You can either write out the individual increments, one by one, or you will use some type of looping.

It's a great exercise for fun perhaps, but as far as teaching you something about C, it has minimal benefit, imo.

class shareef
{
static int a;
public:
shareef()
{
cout<<a++;
}
};
int main()
{
int n;
cout<<Enter given range:"
cin>>n;
shareef *p;
p=new shareef[n];
delete p;
return 0;
}

I hope this will be result.

commented: That's C++, genius. -4
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.