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>
// a function to calculate multiples
int multiple()
{
clrscr()
int i;
cout<<"Numbers between 1 to 50 that are multiple/divisible by 2 and 3 are \n";
for(i=1;i<=50;i++)
{
if (i % 2 ==0 and i %3== 0)
{
cout<<i<<endl;
}
}
return i;
}
//Main function to call multiple function
void main()
{
// calling multiple function
multiple();
getch();
}
The code given below can be used for g++/gcc Compiler:-
#include<iostream>
using namespace std;
// a function to calculate multiples
int multiple()
{
int i;
cout<<"Numbers between 1 to 50 that are multiple/divisible by 2 and 3 are \n";
for(i=1;i<=50;i++)
{
if (i % 2 ==0 and i %3== 0)
{
cout<<i<<endl;
}
}
return i;
}
//Main function to call multiple function
int main()
{
// calling multiple function
multiple();
return 0;
}
#ENJOY CODING
Â
Post a Comment
FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP