print 1 to 100 without Loop

This Program will print 1 to 100 counting without loop in C++ . For this program we used recursive function. A recursive function is that which call itself again and again. The function calling is in the body of the function and when we want to terminate the function we apply some condition to it which called base case.

Source Code

#include<iostream>
using namespace std;
int counting (int start);
int main ()
{
 cout<<"\t \t \t LEP Tutorials \n \n ";
 int start = 1;
 counting(start);
}
int counting (int start)
{
 if (start<=100)
 {
  cout<<start<<"   ";
  counting(start+1);
  }
}

Output of the Program

print 1 to 100 without Loop

Share on Google Plus

About Asad

Asad Niazi is Software Engineer , Programmer, Web Developer and a young mentor of BloggersTown and PProgramming. Asad Love to writes about Technology, Programming, Blogging and make money online.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment