The following program prints the greatest number among three numbers.

**Program 1:** C program to print the greatest of three numbers

#include<stdio.h>intmain() {inta,b,c,large; printf("Enter three numbers: "); scanf("%d %d %d",&a,&b,&c); if(a>b) { if(a>c) large=a; else large=c; } else if(b>c) large=b; else large=c; printf("\nThe largest out of three numbers is: %d\n",large); return 0; }

**Output:** **Prints largest among three numbers**

```
Enter three numbers: 34 85 57
The largest out of three numbers is: 85
```

## Program 2: C program to print the largest among three numbers using function

As I’ve already mentioned in other programs, it is very easy to write functions to solve a problem if you know the algorithm. Therefore, by using above algorithm, we’ll write a C program to print the greatest of three numbers using function.

#include<stdio.h>intlarge(int,int,int); //function prototypeintmain() {inta,b,c; printf("Enter three numbers: "); scanf("%d %d %d",&a,&b,&c); //printing and function calling simultaneously printf("\nThe biggest of three numbers is: %d\n",large(a, b, c)); return 0; } //function definitionintlarge(inta,intb,intc) { // if b is smaller than a if(a>b) { if(a>c) returna; else returnc; } else //if b is greater than a if(b>c) returnb; else returnc; }

**Sample output #1:**

```
Enter three numbers: 342 643 23
The biggest of three numbers is: 643
```

**Sample output #2:**

```
Enter three numbers: 93 27 132
The biggest of three numbers is: 132
```

That’s it. This is how we find and print the greatest among three numbers in C.

Share your code in the comments to help other beginners.