64 584
Assignments Done
99,2%
Successfully Done
In September 2018

Answer to Question #27185 in C++ for Calvin

Question #27185
Write a program that contains a function Min. The function must take two integer numbers a and b. The function must return 1 if a > b, 0 if a equals to b, and -1 if a < b.
Expert's answer
#include <iostream>

using namespace std;

int Min(int a, int b)
{
if (a == b)
& return 0;
return (a > b) ? 1 : -1;
}

int main()
{
int a = 5;
int b = 10;

cout << "a = 5, b = 10" << endl;
cout << "Min(a, b) = " << Min(a, b) << endl;
return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions