By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,479 Members | 1,749 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,479 IT Pros & Developers. It's quick & easy.

area of square

P: 6
How do you write a C++ program that computes the area of a square (area=x*x)
Nov 8 '08 #1
Share this Question
Share on Google+
4 Replies


P: 6
this is how i found the area of a circle
#include <iostream>

using namespace std;

int main ()
{
float area ,pi, radius;
pi= 3.14;
cout << "Which is the radius of the circle? " << "\n";
cin >> radius;
area= pi*(radius*radius);
cout << "The circle has an area of " << area << "\n";
system ("Pause");
Nov 8 '08 #2

100+
P: 424
Replace the line "area=.." with the correct formula for the area of a square.
Nov 8 '08 #3

Expert 10K+
P: 11,448
Just don't multiply by pi (or any other rude approximation thereof), call your
circle a square and your radius a side.

kind regards,

Jos
Nov 8 '08 #4

P: 6
thanks for your help
Nov 8 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.