3
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by Radical Edward
0

> input three numbers and display largest one
Break it down into testing two numbers. Find the largest of the first two, then find the largest of that test and the third. Edward won't do your homework for you, but an example always helps. Here is some code that probably won't be accepted by a teacher but still solidifies the concept:

#include <iostream>

template <typename T>
T maximum(T a, T b)
{
  return a > b ? a : b;
}

int main()
{
  int a = 1;
  int b = 2;
  int c = 3;

  std::cout << maximum(maximum(a, b), c) << '\n';
}
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.