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