C â f é

Programming Café, freshly designed for the programmers, who has too much intend to do programming, coding, designing. Actually, in the programming world, there has unlimited website, web blog for programming & lots of tool for programming.

but, in this site, I would like to give a basic level of programming as well as try to present  from first to finish and rest all levels of the programming. Recently, the link has started and that’s the demo version. I’m establishing this site with my last 7 years experience. Somebody can tell me, why I’m starting to lately.

Because, I think that anyone wants to start programming site, of course, he or she should be required more experience. Though I’m a software engineer but I’m a man, so I have some limitations because I’m not robot. for this, I’m writing for the programming, after a long years.

Programming Café :: Just Try to See, Try to realize and Touch our voice, idea

Recent Posts

Print numbers from 1 to n using loops, recursion or goto statement

You may have made program to print numbers from 1 to n using loops, recursion or goto statement. But have you ever thought about doing this without help of loops, recursion or goto? It can be done without using such things as explained in below program.

#include<iostream>
using namespace std;
class Num
{
    public:
    static int i;
    Num()
    {
        cout<<i++<<” “;
    }
};
int Num::i=1;
int main()
{
    int n;
    cout<<“Enter value on n:”;
    cin>>n;
    Num obj[n];
    return 0;
}
In this program we are using the concept of static data member and array of objects. Class Numcontains a static variable i whose value will remain till the program terminates. We are creating an arrayof objects of class Num. In this program we are creating n objects, value of n depends on input we give. The default constructor is called for all objects one by one. In the constructor the value of i is printed and is incremented by one in each call. In this way numbers from 1 to n are printed.
C++ Program to Print Numbers From 1 to n Without Using Loops, Recursion or Goto Statement
  1. Array Descending Order Leave a reply
  2. Problem 04 | ArrayClass function Leave a reply
  3. Primary and Basic knowledge of C | Leave a reply
  4. Problem 03 Leave a reply