+ 1
What's wrong with this code?
I wanted to make a simple calculator with to int's but something apparently is wrong with this a+b= sum code help me find the problem please Here's the code #include <iostream> using namespace std; int main() { int a,b; cout << "Type one number \n"; cin >> a; cout << a; cout << "Type 2nd number to sum\n"; cin >> b; sum = a + b; cout << "The result is "<< sum << endl; return 0; }
2 odpowiedzi
+ 14
You just have to put an "int" before "sum".
int sum = a + b;
// Just the finished program
#include <iostream>
using namespace std;
int main() {
int a,b;
cout << "Type 1rst number: ";
cin >> a;
cout << a;
cout << "\nType 2nd number: ";
cin >> b;
cout << b;
int sum = a + b;
cout << "\n\nThe result is: "<< sum << endl;
return 0;
}
0
oh thanks alot