C++的一道题.

来源:百度知道 编辑:UC知道 时间:2024/05/25 03:14:49
//sqrt.cpp ---uaing the sqrt

#include <iostream>
#include <cmath> //or math.h

int main()
{
using namespace std;

double area;
cout << "Enter the floor area,in square feet,of you home:";
cin >> area;
double side;
side = sqrt(area);
cout << "that`s the equivalent of square."<<endl;
cout << "feet to the side."<<endl;
cout << "how fascinating!"<<endl;
return 0;
}
请问这段程序有没有错?为什么DEV编出来一个程序后无法运行呢?
谢谢

using namespace std; 应该放在main前面。还有cout的最后面加一个<<endl;要不然不会换行,不好看。你的最后的cout中应该有<<area<<
<<side<<才可能输出你想要的东西,不要放在引号里。
应该改为
cout << "that`s the equivalent of square."<<area<<endl;
cout << "feet to the side."<<side<<endl;
这样才能输出。area和side