the int x=0 isn't really necessary. It could just be written like this:
cin >> x;
It doesn't matter though, it's more stylistic, because when the user inputs for x, cin >> x just replaces 0 with whatever is entered. However, it's also not proper coding style because no error checking is being done to make sure that what is entered is an int, but I'm guessing it's probably an early assignment that doesn't take into account exception handling.
In terms of your second question, minVal, maxVal, and x are all initially assigned to the same value since minVal and maxVal are initially assigned the value of x, but later in the program the values can change based on the conditions set. If a is less than x, then minVal gets reassigned the value of a, and if a is greater than maxVal, maxVal gets reassigned the value of a.