Question-   given that the variables x and y have already been declared and assigned values


Question:- Given the integer variables x, y, and z, write a fragment of code that assigns the smallest of x, y, and z to another integer variable min.

Assume that all the variables have already been declared and that x, y, and z have been assigned values .


Complete solution below:-




using namespace std;

int main(){

            int x,y,z;

            int minVal;

  cout << "Type a number:x= ";

 cin >> x;

  cout << "Type a number:y= ";

 cin >> y;

  cout << "Type a number:z= ";

 cin >> z;

if (x < y)


if (x < z)

minVal = x;


minVal = z;





if (y < z)

minVal = y;


minVal = z;


 cout<<"The Min value are : = "<<minVal;

return 0;         


Our Happy Testimonials

They are fast in responding to homework questions. they have the best technical writers. Thanks for helping me with my programming doubts.

5  stars image

I contact to disklib for homework, they help me out, despite there was some technical issue they gone through extra mile for me and provide me good quality work in first priority. 100% recommended.

studying on laptopAsif Waheed
5  stars image

Desklib's study resources are best & unique. Their study database is easy to access and easy to use.
100 % recommended.

library and studentsMike Taylor
5  stars image