0

Why the answer is one and should be 32??

#include <iostream> using namespace std; int main() { double x,y; char c; // input should be like this " number operation number" cin>>x; // input the first number cin>>c; // input the operation (+,-,*,/) cin>>y; // input the second number switch (c){ case '+' : cout <<x<<"+"<<y<<"="<<x+y; break ; case '-' : cout <<x<<"-"<<y<<"="<<x-y; break ; case '*' : cout <<x<<"*"<<y<<"="<<x*y; break ; case '/' : if(y==0){ cout <<"err

25th Nov 2016, 7:57 PM
MO Nasser
MO Nasser - avatar
2 Answers
+ 4
I dont understand your question, but at first I think case "/" is half done, it should have an "else" option as well and " cout <<x<<"/"<<y<<"="<<x/y; .. Or maybe when you copied it, something went wrong and that is why it is incomplete.
25th Nov 2016, 8:09 PM
LyannaM
LyannaM - avatar
0
It does not look as though this is the complete code... as has been pointed out, your division case is incomplete and there is no break. If C++ behaves like C, it may be returning 1 to tell you that there is an error
6th Jan 2017, 8:09 PM
Aashish Kanji