【发布时间】:2018-08-28 02:20:30
【问题描述】:
我正在尝试做一个简单的数学问题,但我不断收到此错误消息。怎么了?我正在使用cloud9 ide。
/home/ubuntu/workspace/Sphere.cpp:在函数“int main()”中: /home/ubuntu/workspace/Sphere.cpp:20:63:错误:无效的操作数 将“int”和“const char [15]”类型转换为二进制“operator
这是完整的代码:
#include <iostream>
using namespace std;
int main() {
// Declare the radius
int meters;
cout << "Please enter the radius in meters: ";
cin >> meters;
// Calculate Diameter
cout << "The diameter of the circle is: " << meters*2 << "m" << endl;
//Calculate Area
double PI;
PI = 3.14;
cout << "The area of the circle is: " << 3.14*meters^2 << "meters squared" << endl;
}
【问题讨论】:
-
切换 >> 和
-
^不是你想的那样。 -
3.14*meters*meters -
附注:你可以考虑写
PI = 4.0 * atan(1.0)并使用#include <math.h>
标签: c++