Computer Science, asked by ankitsood0123, 2 months ago

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 anindyaadhikari13
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:

  1. Accepting the side of the square.
  2. Calculate the perimeter and area using formula.
  3. Display the perimeter and area of the square.

See the attachment for output.

Attachments:
Similar questions