Okay well I am going to try to make a big calculator, but I am starting off here since this is something I don't understand. Sorry for most likely a very stupid question, but could use your help. Anyways I have this code:
It will let me compile and run. It will ask what I would like to do and when I enter in add or subtract it just says Press any key to continue... and I do and it exits. I don't know what I am doing wrong. I don't know if I need to declare add and subtract or what. I am confused so please a little help here. Thank you...Code:#include <iostream> #include <stdlib.h> using namespace std; int main() { int choice; cout<<"Enter what you want to do.Do so by either entering in add or subtract."<<endl; cin>> choice; if (choice == 'add') { int first; int second; cout<<"Enter in your first number."<<endl; cin>> first; cout<<"Enter in your second number."<<endl; cin>> second; cout<<"The answer is: "<<(first + second)<<endl; } else if (choice == 'subtract') { int first1; int second1; cout<<"Enter in your first number."<<endl; cin>> first1; cout<<"Enter in your second number."<<endl; cin>> second1; cout<<"The answer is: "<<(first1 - second1)<<endl; } system("PAUSE"); return 0; }
Emotions



LinkBack URL
About LinkBacks


