Variable int Output failure

I'm an absolute begginer to coding, I've wanted to learn C++ for a few years and like the idea of creating something thats mine and mine alone, so I bought a book (Bjarne Stroustrup - Principles and Practice using C++).
Im currently working through one of the excercises the book gives you (I am doing this alone so have no outside help) and it asks to put in three seperate variable Integers that are then sorted by the system and Cout in order.

Below is the finished product but its somehow wrong and I can't tell how, if the values put in are;
val1 = 1
val2 = 2
val3 = 3

im outputted with 2, 1, 3 (this is all run from the command prompt)

...help? please?

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 "stdafx.h"
#include <iostream>
using namespace std;
inline void keep_window_open() { char ch; cin >> ch; }

int main()
{
	int val1;
	int val2;
	int val3;
	int min;
	int med;
	int max;
	cout << "This program puts your entered numbers in sequence from 0-10...\n" << "Please enter 3 new digits\n";
	cin >> val1 >> val2 >> val3;
	if (val1 < val2, val1 < val3) {
		min = val1;
		if (val2 < val3) {
			med = val2;
			max = val3;
		}
		else {
			med = val3;
			max = val2;
		}
	}
	if (val2 < val1, val2 < val3) {
		min = val2;
		if (val1 < val3) {
			med = val1;
			max = val3;
		}
		else {
			med = val3;
			max = val1;
		}
	}
	if (val3 < val1, val3 < val2) {
		min = val3;
		if (val1 < val2) {
			med = val1;
			max = val2;
		}
		else {
			med = val2;
			max = val1;
		}
	}
	cout << min << ", " << med << ", " << max; //keeps giving the output "min" to val2??
	keep_window_open();
    return 0;
}
1
2
// if (val1 < val2, val1 < val3)
if (val1 < val2 && val1 < val3)

And like-wise for the other two if statements.

, is the sequencing operator http://en.cppreference.com/w/cpp/language/operator_other#Built-in_comma_operator

&& is the logical AND operator http://en.cppreference.com/w/cpp/language/operator_logical
I swear it's always the simplest things, like forgetting that damn ; so often.
Thanks JLBorges, you're awesome.
Topic archived. No new replies allowed.