Stuck at school assignment!! Please HeLP!!!

Please help me out what's wrong with it?
It said ERROR : Expected a declaration

#include <iostream>;

using std::cout;
using std::cin;
int main();

{
int radius;
cout << "Please enter radius ">>;

const double PI = 3.14159265;

double surface area = 4 × PI^2 × 2radius x radius;

double volume = 2 × PI^2 × 2radius × radius^2;

cout << "The surface area of the torus is: " << surface area << "\n";
cout << "The volume of the torus is: " << volume << "\n";

return 0;
}

The BOLD part is the ERROR point
You have a semicolon after int main that should not be there.
There are a few other errors in your code too. The carrot symbol (^) does not perform the power operation. You should just have PI * PI instead, or you can use pow(PI, 2) from the cmath library (that means you need to #include <cmath>)
Last edited on
Thanks alot it was a very carless mistake.
one more thing that i wanna ask is the surface area is error what can i do...?
You can't have a space in the middle of a variable name.
You haven't declared radius, and you also made another variable 2radius.
Please post specific error messages when asking for help. If the people who wrote the compiler thought it important enough to give those error message, why would you not give the error messages to people trying to help?

1
2
3
double surface area = 4 × PI^2 × 2radius x radius;

double volume = 2 × PI^2 × 2radius × radius^2;

that code should look like this
1
2
3
double surface_area = 4 * PI * PI * radius * radius;

double volume = 2 * PI * PI * radius * radius;

Notice * instead of x and the carrot symbol is not in the code.
thank you * 100
Topic archived. No new replies allowed.