
Dan B. answered 05/03/21
Experienced University Level Tutor in Software Engineering
Hi there, it should be something like this:
#include <iostream>
using namespace std;
//Do not modify anything on or above the line below this
//YOUR_CODE_BELOW
//Here we want to declare the function as specified in the question { } braces to show where the code is for //this function
int myMin(int num1, int num2){
//if num1 is less than '<' num2 then we will 'return' num1!
if(num1 < num2){
return num1;
}
//if num1 is NOT less than num2 then let's check if num2 is less than num1. If so we will 'return' num2!
else if(num2 < num1){
return num2;
}
else{
//Otherwise num1 and num2 must be equal! Since the question didn't specify what to do when that
//happens so you can do whatever you want :P
}
}
//YOUR_CODE_ABOVE
//Do not modify anything on or below the line above this
int main()
{
cout << myMin(4, 8) << endl;
cout << myMin(6, 3) << endl;
cout << myMin(-2, -4) << endl;
}