Simply use the if statement. Writing C code without if statements is harmful and silly practice. If you try to minimize branches in the code, then that's another story, but that's not really a task for a beginner.
That being said, a solution to the problem is to implement a truth table and use boolean algebra with the > operator. Learning how to implement such a table is useful practice (as opposed to avoiding if statements), since boolean algebra has many uses in programming.
In this case, the truth table is (assuming no values are equal):
x>y x>z y>z x largest 1 1 - y largest 0 - 1 z largest - 0 0
Where - means "don't care".
This can be implemented as a 3D array in C, where each index is the result of the corresponding > comparison. That is:
array [2] [2] [2] // x>y x>z y>z
This will however contain some cases that never can be true and the assumption is that no values are equal. You can implement it like this:
#include <stdio.h> int main() { const char* const largest [2] [2] [2] = // x>y x>z y>z { { // x<y { // x<z "z", // y<z "y" // y>z }, { // x>z "-", // y<z, not possible "y", // y>z } }, { // x>y { //x<z "z", //y<z "-" //y>z, not possible }, { //x>z "x", // y<z "x", // y>z }, }, }; const int use_cases [6][3] = { {1,2,3}, {1,3,2}, {2,1,3}, {2,3,1}, {3,1,2}, {3,2,1} }; for(int i=0; i<6; i++) { int x = use_cases[i][0]; int y = use_cases[i][1]; int z = use_cases[i][2]; printf("x:%d, y:%d, z:%d, largest: %s\n", x, y, z, largest[x>y][x>z][y>z]); } return 0; }
Output:
x:1, y:2, z:3, largest: z x:1, y:3, z:2, largest: y x:2, y:1, z:3, largest: z x:2, y:3, z:1, largest: y x:3, y:1, z:2, largest: x x:3, y:2, z:1, largest: x
absgives you the absolute value.if. This is relevant for example in case the reason is a homework assignment (this kind of restrictions are typcically found in them). For that the answer needs to be tailored to the things you have already learned in the course, ideally the answer is tailored to the mechanism the teacher has in mind. A different angle: Be careful to really understand the solution and to be able to explain it based on previous textbook chapters.