Math Operations in If Then Statements Not Working

So, I'm trying to make a simple console based calculator for fun. However, when I use multiple if then statements with my string operation, it only returns addition. Could someone please explain what I'm doing wrong?

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
42
43
44
45
46
47
#include "stdafx.h"
#include <iostream>
#include <Windows.h>
#include <thread>
#include <string>

using namespace std::this_thread;
using namespace std::chrono;
using namespace std;


int main()
{
	SetConsoleTitle(TEXT("Simple C++!"));
	for (int index = 8; index > 0; index--)
	{
		cout << "Loading In: " << index << std::endl;
	}
	sleep_for(seconds(1));
	cout << "Simple Calc Loaded! Type Your First Number To Begin\n";
	int input1;
	int input2;
	string operation;
	bool isended = false;
	while (isended == false)
	{
		cin >> input1;
		cout << "Now Type The Name Of The Operation!\n";
		cin >> operation;
		if (operation == "Addition" || "addition")
		{
			cout << "Now Your Second Number\n";
			cin >> input2;
			cout << "Ok! Your Anwser is: " << input1 + input2 << endl;
		}
		else if((operation == "Subtraction" || "subtraction"));
		{
			cout << "Now Your Second Number\n";
			cin >> input2;
			cout << "Ok! Your Anwser is: " << input1 - input2 << endl;
		}
	}

	int pause;
	cin >> pause;
	return 1;
}
if (operation == "Addition" || "addition")

This means

if (thing on left evaluates true || thing on right evaluates true)

What is the thing on the left?
operation == "Addition"
This will sometimes evaluate true, sometimes not.

What is the thing on the right?
"addition"
This will ALWAYS evaluate true. It's not a test like == ; it's just a non-zero statement.

So in your || statement, the thing on the right is ALWAYS true, so your || statement is
if (operation == "Addition" || true)



thank you sir, that was very helpful. my problem is solved. I changed it to:
if((operation == "Addition") || (operation == "addition"))
Topic archived. No new replies allowed.