Created
January 21, 2011 02:30
-
-
Save llimllib/789153 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
using namespace std; | |
int main() | |
{ | |
//let's init some vars | |
double num1 = 0; | |
double num2 = 0; | |
double sum = 0; | |
char add; //define a random value | |
char op1 = 'a'; | |
char op2 = 'A'; | |
char op3 = '+'; | |
//we can now ask the user for an input choice and their numbers | |
cout << "Please enter your first number... "; | |
cin >> num1; | |
cout << endl << "Please enter your second number... "; | |
cin >> num2; | |
cout << endl << "Please enter a selector for adding, 'a', 'A' or '+'... "; | |
cin >> add; //get the input for the add char | |
cout << "\n\n"; //make some space | |
//now we start the choice sequence | |
if(add == op1) | |
sum = num1 + num2; | |
cout << "Number 1 plus Number 2 is " << sum; | |
else | |
cout << "You entered an incorrect character" << endl; | |
//now we pause and end the program | |
cin.clear(); //clear cin | |
cin.sync(); //reinitialize it | |
cin.get(); //pause and wait for an enter | |
return 0; | |
} | |
/* | |
==================================== | |
part3.cpp: In function ‘int main()’: | |
part3.cpp:26: error: lvalue required as left operand of assignment | |
part3.cpp:28: error: ‘else’ without a previous ‘if’ | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment