Â
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>
// Creating a function to reverse a number
int reverse()
{
clrscr();
int n;
cout << "Enter value of n , from which you want to print till 1? \n";
cin >> n;
int i = n;
cout << "Here are the numbers :\n";
while (i >= 1)
{
cout << i << endl;
i--;
}
return i;
}
void main()
{
clrscr();
// calling reverse function
reverse();
getch();
}
The code given below can be used for g++/gcc Compiler:-
#include<iostream>
using namespace std;
int reverse()
{
int n;
cout << "Enter value of n , from which you want to print till 1? \n";
cin >> n;
int i = n;
cout << "Here are the numbers :\n";
while (i >= 1)
{
cout << i << endl;
i--;
}
return i;
}
int main()
{
reverse();
return 0;
}
#ENJOY CODING
Post a Comment
FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP