Why is this happening?

Just starter to learn C++ and wanted to play about a bit and for some reason the code is not working the way it should be.
Why dose the switch not give any output? Please HELP!!!


enter in your two favourite numbers.
number 1: 2 
number 2: 4
the numbers that you have entered are: 2, 4
the sum of those numbers when multiplayed is: 8
your second number is greater then your first number. the diffrance is: 2


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
48
49
50
51
52
 #include <iostream>
using namespace std;

int main()
{
	int FNumber1, FNumber2;
	int Answer;
	int Diffrance;

	cout << "Enter in your two favorite numbers." << endl;

	cout << "Number 1: ";
	cin >> FNumber1;

	cout << "Number 2: ";
	cin >> FNumber2;

	Answer = FNumber1*FNumber2;

    cout << "The numbers that you have entered in are: " << FNumber1 << ", " << FNumber2 << "." << endl;
	cout << "The sum of those numbers when multiplyed is: " << Answer << "." << endl;
	
	switch (FNumber1, FNumber2)
	{
	case 1: FNumber1 < FNumber2;

		Diffrance = FNumber2 - FNumber1;

		cout << "Your second number is grater then you first number. The Diffrance is: " << Diffrance << "." << endl;

		break;

	case 2: FNumber1 > FNumber2;

		Diffrance = FNumber1 - FNumber2;

		cout << "Your first number is greater then your second number. The diffrance is: " << Diffrance << "." << endl;

		break;

	case 3: FNumber1 = FNumber2;

		cout << "Your numbers are the same." << endl;

		break;
	}


	 system("pause");

		 return 0;
}
Why dose the switch not give any output?


Line 23: This doesn't work the way you expect. Only FNumber2 is used as the switch variable.
See the comma operator here:
http://www.cplusplus.com/doc/tutorial/operators/

Line 25, 33, 41: These comparisons do nothing. BTW, line 41 is an assignment, not a comparison.


Last edited on
Topic archived. No new replies allowed.