Syn*_*ror 2 c++ function function-prototypes
我正在看一个计算3个数字平均值的程序
#define EXIT_SUCCESS 0
Run Code Online (Sandbox Code Playgroud)
使return EXIT_SUCCESS;工作没有错误(在包含标题下).什么是使用的目的#define EXIT_SUCCESS 0和return EXIT_SUCCESS;和没有任何替代品吗?是return 0;吗?感谢您的时间.
这是我正在查看的程序的代码:
#include <iostream>
#define EXIT_SUCCESS 0
using namespace std;
int main()
{
// prototypes:
float add_and_div(float, float, float);
// variables:
float x, y, z;
float result;
cout << "Enter three floats: ";
cin >> x >> y >> z;
// continue the program here
result = add_and_div( x, y, z );
cout<< "Average is \n" << result;
return EXIT_SUCCESS;
}
// function definition:
float add_and_div(float n1, float n2, float n3)
{
// continue the program here
return ( n1 + n2 + n3 ) / 3;
}
Run Code Online (Sandbox Code Playgroud)