+ 2
Can anyone help me? I want to put two numbers in and have their sum be the output
7 Respostas
+ 8
Just change the order, you can't calculate the sum without knowing the values of x and b :)
So first take input, then calculate y.
https://code.sololearn.com/cR9C779b4vlx/?ref=app
+ 3
int x,b,y;
cout<<"enter two numbers";
cin>>x>>b;
y=x+b;
cout<<y;
+ 3
Thank you for all your answers! I know the question was basic but I'm just starting at this.
+ 2
This code can be helpful to you
https://code.sololearn.com/c0QqMzlIJVqD/?ref=app
+ 2
I think that the problem with your code is this:
You should put cin before you declare the variable "y" for the sum...
+ 2
int main() {
int x, y, z;
std::cout << "Enter two integers: ";
std::cin >> x >> y;
z = x + y;
std::cout << "The sum of " << x;
std::cout << " & " << y << " is ";
std::cout << z << std::endl;
return 0;
}
0
Don't you worry... I've had the same problem when I started programming😉✌✌