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