我刚开始使用 c++,只是在玩一些前几天学到的东西,而我编写的这个程序除了试图弄清楚如何在用户输入中使用可返回参数之外没有真正的目的。当我尝试编译这个时,整个事情就变得疯狂了。它出什么问题了?
这是我写的代码:
#include <iostream>
// defining the Parameters of Add and Multply
int add(int a, int b)
{
return a + b;
}
int multiply(int c, int d)
{
return c * d;
}
int main ()
{
using namespace std;
// user defines vairables
int x;
int y;
int w;
int z;
cout << "enter x value now:" << endl;
cin >> x >> endl;
cout << "enter y value now" << endl;
cin >> y >> endl;
cout << "enter w value now" << endl;
cin >> w >> endl;
cout << "enter z value now" << endl;`
cin >> z >> endl;
//computation of variables
cout << "computing x and y factors" << add(x, y) << endl;
cout << "computing w and z cordinates" << multiply(w, z) << endl;
cout << " " << endl;
cout << "final answer is: " << add(x, y) + multiply(w, z) << endl;
cin.clear();
cin.ignore(255, '\n');
cin.get();
return 0;
}