Â
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 table()
{
int n;
int i=1;
cout<<"Enter the no. to get its table : \n";
cin>>n;
do
{
cout<<n<<" * "<<i<<" = "<<n*i<<endl;
i++;
}
while(i<=10);
return n*i;
}
void main()
{
clrscr();
table();
getch();
}
The code given below can be used for g++/gcc Compiler:-
#include<iostream>
using namespace std;
int table()
{
int n;
int i=1;
cout<<"Enter the no. to get its table : \n";
cin>>n;
do
{
cout<<n<<" * "<<i<<" = "<<n*i<<endl;
i++;
}
while(i<=10);
return n*i;
}
int main()
{
table();
return 0;
}
#ENJOY CODING
Post a Comment
FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP