write c++ program to compute area of square
Answers
Answer:
tsdgrskdysjrtsgkkyddkdylrwtisktsdktsjg
Answer:
The formula to calculate the area of a square is:
Area = length * length
Example: C++ program to calculate the area of square
/* program to calculate the area of square */
#include <iostream>
using namespace std;
int main() //function main begins program execution
{
int square_area, square_side;
cout << "Enter the side of square:";
cin >> square_side;
square_area = square_side * square_side;
cout << "Area of Square: " << square_area << endl;
return 0;
} // end main
Output
c++ program to find the area of square - output
Example: C++ program to calculate the area of square using function
/* program to calculate the area of square using function */
#include <iostream>
using namespace std;
void area(); //function prototype
int main() //function main begins program execution
{
area(); //function call
return 0;
} // end main
void area() //called function
{
int square_area, square_side;
cout << "Enter the side of square:";
cin >> square_side;
square_area = square_side * square_side;
cout << "Area of Square: " << square_area << endl;
} //end function area
Output
C++ program to calculate the area of square using function