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:-
#include<stdio.h>
#include<iostream>
#include<stdlib.h>
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;
else
minVal = z;
}
else
{
if (y < z)
minVal = y;
else
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.
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.
Desklib's study resources are best & unique. Their study database is easy to access and easy to use.
100 % recommended.