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
|
int main()
{
int val1=9;//initiate value integer
int val2=1;//initiate value integer
int val3=5;//initiate value integer
cout<<"please enter three integers" <<'\n'; //ask for value
cin>>val1>>val2>>val3;//user enters value
int low; //initiate the lowest number
int mid; //initiate the middle number----these will be the outputs to screen
int high; //initiate the higheste number
if (val1<=val2, val1<=val3) //this block of if statements finds where val1
low=val1; //should be in the sequence
else if (val1>=val2, val1<=val3)
mid=val1;
else if (val1>=val2, val1>=val3)
high=val1;
if (val1==low,val2<=val3) //this block then checks against where val1 is located
mid=val2, high=val3; //i.e is it low, mid, high, then allocates the remaining
else if (val1==low,val2>=val3) // values according to where they come in sequence
high=val2, mid=val3;
else if (val1==mid,val2<=val1)
low=val2, high=val3;
else if (val1==mid,val2>=val1)
high=val2, low=val3;
else if (val1==high,val2<=val3)
low=val2, mid=val3;
else if (val1==high,val2>=val3)
low=val3, mid=val2;
//print result to screen
cout<<"your values in ascending order are "<<low<<", "<<mid<<", "<<high<<'\n';
return 0;
}
|