 # C Programming Code Examples

## C > Mathematics Code Examples

### C Program to Find the Biggest of 3 Numbers

``` C Program to Find the Biggest of 3 Numbers This program takes the 3 numbers and finds the biggest among all. - Take the three numbers as input. - Check the first number if it greater than other two. - Repeat the step 2 for other two numbers. - Print the number which is greater among all and exit. #include <stdio.h> void main() { int number1, number2, number3; printf("Enter the values of number1, number2 and number3\n"); scanf("%d %d %d", &number1, &number2, &number3); printf("number1 = %d\tnumber2 = %d\tnumber3 = %d\n", number1, number2, number3); if (number1 > number2) { if (number1 > number3) { printf("number1 is the greatest among three \n"); } else { printf("number3 is the greatest among three \n"); } } else if (number2 > number3) printf("number2 is the greatest among three \n"); else printf("number3 is the greatest among three \n"); } Take the three numbers and store it in the variables number1, number2 and number3 respectively. Firstly check if the number1 is greater than number2. If it is, then check if it is greater than number3. If it is, then print the output as "number1 is the greatest among three". Otherwise print the ouput as "number3 is the greatest among three". If the number1 is not greater than number2, then check if number2 is greater than number3. If it is, then print the output as "number2 is the greatest among three". Otherwise print the output as "number3 is the greatest among three". ``` 