Printing number from 1 to n || Functions in C++ || Functions || C++
In this, we are going to see Functions, the program is based on function which Calculates, Profit or Loss.

The code given below can be used for TURBO C++ Compiler:-

#include<iostream.h>
#include<conio.h>
int number;

void user_input()
{
    cout<<"Enter the number till where you want the list of numbers\n";
    cin>>number;
}

void process()
{
    for(int i=1; i<=number; i++)
    {
        cout<<i<<endl;
    }
}

void main()
{
    clrscr();
    user_input();
    process();

    getch();
}
	
    
The code given below can be used for g++/gcc Compiler:-

#include<iostream>
using namespace std;

int number;

void user_input()
{
    cout<<"Enter the number till where you want the list of numbers\n";
    cin>>number;
}

void process()
{
    for(int i=1; i<=number; i++)
    {
        cout<<i<<endl;
    }
}

int main()
{
    user_input();
    process();

    return 0;
}
	
    
#ENJOY CODING

Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post