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)

 ``12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152`` ``````#include "stdafx.h" #include 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; }``````
 ``12`` ``````// 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.