Write a program to enter the Write a program to enter the side of a square and print its area and perimeter
in c++ program
Answers
Answered by
2
Answer:
This is the required program for the question in C++.
#include <iostream>
using namespace std;
int main() {
float s,p,a;
cout << "Enter the side of the square: ";
cin >> s;
a=s*s;
p=4*s;
cout << "Area of the square is " << a << " square units.\n";
cout << "Perimeter of the square is " << p << " units.";
return 0;
}
Algorithm:
- Accepting the side of the square.
- Calculate the perimeter and area using formula.
- Display the perimeter and area of the square.
See the attachment for output.
Attachments:
Similar questions