code outputs 1 and i dont know why.
when i execute this it outputs 1 right before answer and i dont know why.
i'd appreciate it if you explain it :)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
#include <iostream>
int main () {
std::cout<<"----------------------------------------------------------------\n";
int num1
;
int num2;
char parameter;
int sum, sub, mult, div;
std::cout<<"enter first number: ";
std::cin>>num1
;
std::cout<<"\n";
std::cout<<"enter action: ";
std::cin>>parameter;
std::cout<<"\n";
std::cout<<"enter second number: ";
std::cin>>num2;
std::cout<<"\n";
std::cerr<<main;
if(parameter == '+'){
sum = num1 + num2;
std::cout<<"\n Answer: "<<sum<<std::endl;
}
else if(parameter == '-'){
sub = num1 - num2;
std::cout<<"\n Answer: "<<sub<<std::endl;
}
else if(parameter == '*'){
mult = num1 * num2;
std::cout<<"\n Answer: "<<mult<<std::endl;
}
else if(parameter == '/'){
div = num1 / num2;
std::cout<<"\n Answer: "<<div<<std::endl;
}
}
|
oh nvm i just remembered i put CERR :D oopsie
Topic archived. No new replies allowed.