A Calculator
Here it is:
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 37 38 39 40 41
|
#include <iostream>
#include <cmath>
int main()
{
using namespace std;
int a;
int b;
int c;
char addition;
char subtraction;
char multiplication;
char division;
int answer;
cout <<" Calculator !!! " << endl;
cout <<" Made by UdAy ShArMa the GREAT!!! " << endl;
cout <<" PLease ENTER a number. " << endl;
cin >> a;
cout << " PLease ENTER the operation: (1) addition,(2) subtraction,(3) multiplication,(4) division. " << endl;
cin >> b;
cout << " PLease ENTER another number. " << endl;
cin >> c;
if (b == 1){
answer = a + c;
}
if (b == 2){
answer = a - c;
}
if (b == 3){
answer = a * c;
}
if (b == 4){
answer = a / c;
}
cout << " Your anSwer is "<< answer <<", OMG that's sooo cool. "<< endl;
return 0;
}
| |
??????????????????????????????????
Damn encoding, I can't see any character Shinigami.
it works
Instead of what you have, it should look more like this*:
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 37 38 39
|
#include <iostream>
// Notice how I got rid of cmath. You didn't use it at all in your program.
int main()
{
using namespace std;
int a;
int b;
int c;
char addition;
char subtraction;
char multiplication;
char division;
int answer;
cout <<" Calculator !!! " << endl;
cout <<" Made by UdAy ShArMa the GREAT!!! " << endl;
cout <<" PLease ENTER a number. " << endl;
cin >> a;
cout << " PLease ENTER the operation: (1) addition,(2) subtraction,(3) multiplication,(4) division. " << endl;
cin >> b;
cout << " PLease ENTER another number. " << endl;
cin >> c;
if (b == 1){
answer = a + c;
}
else if (b == 2) {
answer = a - c;
}
else if (b == 3) {
answer = a * c;
}
else {
answer = a / c;
}
cout << " Your anSwer is "<< answer <<", OMG that's sooo cool. "<< endl;
return 0;
}
| |
I'm not going into how you could use an array to let them input as many numbers and operations as they like.
Oh wait, were you just showing off the code? Or asking for help?
*Note that I'm not referring to your formatting.
yo don't im just 12
Don't what? Age is irrelevant.
Topic archived. No new replies allowed.