Answer to Question #128364 in C++ for Zeeshan Ali

Question #128364
Write a function that takes two Distance values as arguments and returns the larger one. Include a main() program that accepts two Distance values from the user, compares them, and displays the larger.
1
Expert's answer
2020-08-06T03:58:54-0400
#include <iostream>

int Comparer(int firVal, int secVal)
{
  if (firVal > secVal)
  return firVal;
  else
  return secVal;
}

int main()
{
 int firVal, secVal;
 std::cout << "Enter first Distance value: ";
 std::cin >> firVal;
 std::cout << "Enter second Distance value: ";
 std::cin >> secVal;
 std::cout << "The larger value is " << Comparer(firVal, secVal) << ".";
 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