20th Apr 2018, 4:15 PM
Aditya Sankhla
Aditya Sankhla - avatar
4 odpowiedzi
+ 1
//Does it work like this? #include <iostream> using namespace std; int main() { int x; int y; cout<<"Please type a number\n"; cin>>x; cout<<"Please type another number\n"; cin>>y; int sum=x+y; int difference=x-y; int multiply=x*y; int divide=x/y; int modulus=x%y; cout<<"Their sum is"<<sum<<"\n" <<"Their difference is"<<difference<<"\n" <<"Their multiplication is"<<multiply<<"\n" <<"Their division is"<<divide<<"\n" <<"Last but not the least,Their remainder is"<<modulus<<"\n"; cout<<"Thanks and please guide me as I am just starting out and it will really motivate me!!" <<"-ARTN"; return 0; }
20th Apr 2018, 4:17 PM
Timon Paßlick
+ 1
Because your program is run from top to bottom. And if you place this in front of the "cin >>" statements, x and y are just trash values.
20th Apr 2018, 4:22 PM
Timon Paßlick
0
let me try
20th Apr 2018, 4:18 PM
Aditya Sankhla
Aditya Sankhla - avatar
0
it worked can u kindly tell me the reason.... thx a lot btw
20th Apr 2018, 4:20 PM
Aditya Sankhla
Aditya Sankhla - avatar