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.
1
Expert's answer
2013-03-29T07:49:17-0400
#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 the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS