Sunday, May 22, 2016

List of Numbers Without Using a Loop in C++

A simple program that I  wrote in C++ that will list down  a  number from one to fifty without using a looping statement in C++. The code is very short and easy to understand.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.




Sample Program Output


Program Listing

#include <iostream>
#include <stdlib.h>

using namespace std;

int print(int num){
    if(num<=50){
         cout << " " << num << " ";
          print(num+1);
    }
}


int main(){
    int num = 1;
    cout << "\nList of Numbers Without Using a Loop in C++";
    cout <<"\n\n";
    print(num);
    cout <<"\n\n";
    cout << "\nEnd of Program";
    cout <<"\n\n";
    system("pause");

}



No comments:

Post a Comment