【发布时间】:2021-03-05 09:22:53
【问题描述】:
我是使用函数的初学者,我编写了这个简单的代码。但是我不知道为什么音量总是被计算为零。
#include <iostream>
using namespace std;
double area (double) ;
double volume (double) ;
int main () {
double radious ;
cout << "please enter the Radious \n" ;
cin >> radious ;
cout << "The area = " << area(radious) << "\n" ;
cin >> radious ;
cout << "The volume = " << volume(radious) << "\n" ;
cout << radious << "\n" ;
}
// defintion function of the area
double area (double R) {
return ( (4) * (3.14) * (R * R) ) ;
}
// defintion function of the volume
double volume (double R) {
return ( (3/4) * (3.14) * (R * R * R) ) ;
}
【问题讨论】:
-
Please do not post images of code because they are hard to use. 代码应作为文本直接发布在您的问题中。
-
问题中包含代码,请勿发图。
3/4是0,0乘以任意值是0。 -
(3 / 4)为零,因为这是整数除法。