I decided to write the code in such a manner where both inputs are from the user and the system adds the value to give the sum of the 2 values provided by the user. but the out is different from what I expected it to do. please refer to the respective attached block of the result
*I really hope that someone could help me understand what exactly is going on with the block of code I have written, Please also help me with typing the code more efficiently -`
Please refer to my code and attachments
Here is my actual code
`
#include <iostream>
#include <string>
using namespace std;
int main()
{
int nm1, nm2;
cout<<"Your numbers please";
cin >> nm1, nm2 ;
cout << nm1 + nm2;
return 0 ;
}
`
I was expecting a sum and it gave me some sort of a big surprise
PS E:\programmes\C programming> cd "e:\programmes\C programming" ; if ($?Your numbers please1 2 4201052 PS E:\programmes\C programming> cd "e:\programmes\C programming" ; if ($?) { g++ c++intros2.cpp -o c++intros2 } ; if ($?) { .\c++intros2 } Your numbers please1 4201052
I also hope that someone could give me some intel and also provide me with a good and more efficient code instead of referring me to this one -
`
#include <iostream>
#include <string>
using namespace std;
int main()
{
int nm1, nm2;
cout<<"Your numbers please";
cout << "Your 1st number please";
cin >> nm1 ;
cout << "Your 2nd number please";
cin >> nm2 ;
cout << nm1 + nm2;
return 0 ;
}
`
Thanking you