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)
#include "stdafx.h"
#include <iostream>
usingnamespace std;
inlinevoid 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;
}