help me

Mar 23, 2016 at 12:00am
I am trying to make a simple calculator but it isn't working can someone help

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
 #include <iostream>


using namespace std;

int main()
{

    int a;
    int b;
    int answer;
    int c;

    cout << "enter a number! \n \n";
    cin >> a;
    cout << "now which operation should we use \n \n";
    cin >> c;
    cout << "enter another nummber \n \n";
    cin >> b;





    if(c = *)
    {a * b = answer;}

    if(c = / )
    {a / b = answer;}

    if(c = +)
    {a + b = answer;}

    if(c = -)
    { a - b = answer;}

    cout << "your answer is \n" << operation << endl;

}
Mar 23, 2016 at 12:18am
There's many problems here. What does the compiler tell you? Yes I can fix this for you but I want you to work through it as the errors are very basic ones for almost any language.
Mar 23, 2016 at 12:26am
expected primary-expression before ")" token
Last edited on Mar 23, 2016 at 12:26am
Mar 23, 2016 at 12:31am
Take a look at you if-statements. They are not specifying chars to compare against. It's using actual arithmetic operators. You want characters. When you need an actual single character, you must wrap it in single quotes.

Example:
char c = '2';
This assigns it the character '2'.

char c = 2;
this assigns it the VALUE of 2. Do you see the difference?

Also the operator you are using to do the comparison is incorrect. Fix the code above.
Topic archived. No new replies allowed.