Answer to Question #307791 in Geometry for Jiha

Question #307791

 Write C++ program that calculates the area and the circumference of a square. Read the

required input from the user at the runtime. Where area = edge2 and circumference = 4 edge


1
Expert's answer
2022-03-09T04:15:34-0500

Solution


Code For Perimeter/ Circumference of a Square

#include<iostream>

using namespace std;

int main()

{

  float length, perimeter;

  cout<<"Enter the Length of the Square: ";

  cin>>length;

  perimeter = 4*length;

  cout<<"\nPerimeter = "<<perimeter;

  cout<<endl;

  return 0;

}


Output (https://www.programiz.com/cpp-programming/online-compiler/) and online compiler




Code For Area of a Square

#include<iostream>

using namespace std;

float areaOfSquare(float);

int main()

{

  float length, area;

  cout<<"Enter the Length of the Square: ";

  cin>>length;

  area = areaOfSquare(length);

  cout<<"\nArea = "<<area;

  cout<<endl;

  return 0;

}

float areaOfSquare(float length)

{

  return (length*length);

}

Output (https://www.programiz.com/cpp-programming/online-compiler/) and online compiler







Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS