Programming Challenge Chapter 4 – Q #1 Minimum/Maximum – Tony Gaddis – Starting Out With C++
Problem: -
Solution: -
#include<iostream>
using namespace std;
int main()
{
//Declare Variables
int num1, num2;
int min, max;
//Take Input From The User
cout << "Enter 1st Number:
";
cin >> num1;
cout << "Enter 2nd Number:
";
cin >> num2;
//Use Conditional Operator
For Minimum & Maximum
min = num1 < num2 ? num1 : num2;
max = num1 > num2 ? num1 : num2;
//Output On The Scree
cout << "Smaller Number is
" << min << endl;
cout << "Larger Number is
" << max << endl;
//Return Value To The Main
Function
return 0;
}
This is the solution of this question
OUTPUT OF THIS QUESTION
Explanation of this Solution
Solution Explain With Comments in Solution.
0 Comments