Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++. Write a program that inputs two numbers and determines which of the two num

ID: 3823730 • Letter: C

Question

C++. Write a program that inputs two numbers and determines which of the two numbers is the smallest. If the numbers are equal, display a message that they are equal. Using the pseudocode below, write the code that will meet the requirements: Display description of program Prompt the user for the first number Prompt the user for the second number If first number equals second number Display the two numbers are equal Else If first number is greater than second number Assign second number to smallest Else Assign first number to smallest End-If Display smallest number End-If

Explanation / Answer

#include <iostream>

using namespace std;

int main()
{
int first, second;
cout<<"Enter the first number: ";
cin >> first;
cout<<"Enter the second number: ";
cin >> second;
if(first < second){
cout<<"Small value is "<<first<<endl;
}
else if(second < first){
cout<<"Small value is "<<second<<endl;
}
else{
cout<<"Both values are equals"<<endl;
}
return 0;
}

Outpu:

sh-4.2$ g++ -o main *.cpp                                                                                                                                                                                                                                                

sh-4.2$ main                                                                                                                                                                                                                                                             

Enter the first number: 4                                                                                                                                                                                                                                                

Enter the second number: 5                                                                                                                                                                                                                                               

Small value is 4                                                                                                                                                                                                                                                         

sh-4.2$ main                                                                                                                                                                                                                                                             

Enter the first number: 4                                                                                                                                                                                                                                                

Enter the second number: 4                                                                                                                                                                                                                                               

Both values are equals

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote