Pages

Friday, July 05, 2013

Write a program to find Area of a Rectangle in C++

Area of a Rectangle  =  h * w

Source Code:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
   #include <iostream.h>
   #include <conio.h>
   int main()
   {
   cout << "   Area of rectangle = h * w \n";
   float A, h, w;
   cout << "Enter the value of h <height>?\n";
   cin  >> h;
   cout << "Enter the value of w <Width>?\n";
   cin  >> w;
     A  = w * h;
   cout <<"\t Area of rectangle = " << A << " m^2 " << endl;
   getch();
   return 0;
            }// end main

Output:

   Area of rectangle = h * w 
Enter the value of h <height>?
45
Enter the value of w <Width>?
63
 Area of rectangle = 2835 m^2 

No comments:

Post a Comment