小编Khi*_*mad的帖子

C++问题每次运行程序时,我都会输出"nan"作为输出

我被要求创建一个程序,其功能可以以米为单位改变高度到高度.我提出的功能,当我从功能清点我得到正确的值,但是当我在主清点它,我得到"男".我不明白为什么价值不打印.这是我第一次使用这个网站,所以如果我错过了什么,我很抱歉.

#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;


double heightInMeters(double feet , double inches)
{
double footToMeter = 0.305;
double inchToMeter = 0.0254;

double heightInMeters = ((footToMeter * feet) + (inchToMeter * inches));
cout << heightInMeters << endl;
}


int main()
{

double feet, inches, calcheight;
char ch;

cout << "Enter your height [Use format ft-in]: ";
cin >> feet >> ch >> inches;

calcheight = heightInMeters(feet, inches);
cout << calcheight << endl;

return 0;
}
Run Code Online (Sandbox Code Playgroud)

c++ function nan

6
推荐指数
1
解决办法
486
查看次数

标签 统计

c++ ×1

function ×1

nan ×1