basic calculator troubles

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
#include <iostream>
using namespace std;

int main (){
    int a;
    char b [10];
    int c;
	cout<< "please enter a number \n";
	cin >> a;
	cout << "please enter your operator (times, subtract, divide, add) \n";
	cin >> b;
	cout << "please enter the final number \n";
	cin >> c;
	if (b=="times"){
		cout << a*c;
	}
	else if (b=="sub
	tract"){
		cout << a-c;
	} 
	else if (b=="divide"){
		cout << a/c;
	}
	else if (b=="add"){
		cout << a+c;
	}
	else{
		cout<< "this is not valid \n";
	}
	
	return 0;
}


well for the b== parts what should i put that as seeing that it will be a worded value?
figured it out. It should've been a string not a char because it measured the characters.
Topic archived. No new replies allowed.