Pages

Friday, July 05, 2013

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

Area of a square = l^2
    l = length of side

Source Code:


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
    #include <iostream.h>
    #include <conio.h>
    int main()
    { 
     int l, l2;   
     cout << " Area of a square = l^2\n";   
     cout << " Enter the value of length?\n";
     cin  >> l;
     l2 = l * l;
     cout << "\t" << "Area of a square = " << l2 << " m^2 " << " \n";   
     getch();
     return 0;
        } // end main 

Output:


 Area of a square = l^2
 Enter the value of length?
7
 Area of a square = 49 m^2

No comments:

Post a Comment