To find the maximum of three numbers in C, you can use a simple comparison with if statements.
In this example,
a
, b
, and c
with the numbers to compare.#include <stdio.h>
int main() {
int a = 5;
int b = 8;
int c = 3;
int max = a;
if (b > max) {
max = b;
}
if (c > max) {
max = c;
}
printf("Maximum of three numbers is: %d\n", max);
return 0;
}
Maximum of three numbers is: 8
In this tutorial, we learned How to find the Maximum of Three Numbers in C language with well detailed examples.