Â
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>
float calculate_area(float b, float h)
{
float area;
area = b * h;
cout << "The Area of the Parallelogram with base " << b << " and height " << h << " is = " << area;
}
void main()
{
clrscr();
float base, height;
cout << "\nEnter the Base and Height of the Parallelogram\n";
cin >> base >> height;
calculate_area(base, height);
getch();
}
The code given below can be used for g++/gcc Compiler:-
#include<iostream>
using namespace std;
float calculate_area(float b, float h)
{
float area;
area = b * h;
cout << "The Area of the Parallelogram with base " << b << " and height " << h << " is = " << area;
}
int main()
{
float base, height;
cout << "\nEnter the Base and Height of the Parallelogram\n";
cin >> base >> height;
calculate_area(base, height);
return 0;
}
#ENJOY CODING
Post a Comment
FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP