#include <iostream>
#include <iomanip>
using namespace std;
int main () // print to console: 3.0*5.0=15.00
{
double a;
double b;
a =(3.0);
b =(5.0);
cout << " " << fixed << setprecision (1) << a << "\n" << endl;
cout << "* " << b << "\n" << endl;
cout << "------" << endl;
cout << fixed << setprecision (2) << a*b << "\n" << endl;
return 0;
}
int calculate () // print to console: (7.1*8.3)-2.2=56.73
{
double a;
double b;
double c;
a = (7.1);
b = (8.3);
c = (2.2);
cout << " " << fixed << setprecision (1) << a << "\n" << endl;
cout << "* " << b << "\n" << endl;
cout << "- " << c << "\n" << endl;
cout << "------" << endl;
cout << setprecision(2) << (a*b)-c << "\n" << endl;
}
int calculation () // print to console: 3.2/(6.1*5.0)=0.10
{
double a;
double b;
double c;
a=(3.2);
b=(6.1);
c=(5.0);
cout << " " << fixed << setprecision (1) << a << "\n" << endl;
cout << b << "*" << c << endl; //how can I use variables instead of using quotes?
cout << "------" << endl;
cout << setprecision(2) << a/(b*c) << "\n" << endl;
system("PAUSE");
return 0;
}
此输出错误是什么意思?我如何解决它?有人请向我解释一下。我想补充一下:int calculate(int a, int b, int c)
?
输出:
(32): error C4716: 'calculate' : must return a value
答案 0 :(得分:0)
您已将函数声明为返回int
值的函数,但没有return
语句。如果您不需要从中返回值,请尝试将声明更改为void calculate()
。
答案 1 :(得分:0)
calculate
函数需要返回一个值。
您需要在calculate
:
return (a*b)-c;
答案 2 :(得分:0)
这只是因为你的计算函数应该返回int
你的职能没有回报。
如果您不想退回任何内容,可以改为void calculate()