well, the exercise is do a program that read 3 numbers and show who is the greater.
example: 4,8,1 the greater is 8.
is easy but I can't use "if" so that is my problem, beacuse i'm a begginer in c++ but I see the lesson about the conditionals , but I don't know how this problem . please do you help me whit this?
As has already been said, yes. Use the ternary operator.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#include <iostream>
int max(int a, int b)
{
return a < b ? b : a;
}
int main()
{
int a = 4;
int b = 8;
int c = 1;
std::cout << "The greater is " << max(a, max(b,c)) << '\n';
}
ah ok, I understand now, sorry, i'm from venezuela (we speak spanish) and I don't speak perfect english, that operator I meet with other name , I had not understood.