C Program To Find Largest of Three Numbers ( 3 Different Ways )

In this article, we are going to write a c program to find Largest of Three Numbers.

We will make this program in the following way -:

  • C Program to find Largest of Three numbers (Simple Way)
  • C Program to find Largest of Three numbers using function
  • C Program to find Largest of Three numbers using conditional operator

To make this program, we will use the following concept given below. If you do not know about these topics well, then you may not understand this program, so you should know about them in detail from the link given below.

Now without wasting time let’s start programming.

C Program To Find Largest of Three Numbers

C Program To Find Largest of Three Numbers (Simple Way)

Program -:

//C Program To Find Largest of Three Numbers (Simple Way)

#include<stdio.h>
void main()
{
  // Variable declaration
   int a,b,c, larg;

   printf("Enter Three Number\n");
   scanf("%d %d %d",&a,&b,&c);

  // larg among a, b and c
  if(a>b)
  {
      if(a>c)
        larg = a;
      else
        larg = c;
  }
  else
  {
      if(b>c)
        larg = b;
      else
        larg = c;
  }

  //Display Largest number
    printf("Largest Number is : %d",larg);

}

Output -:

Enter Three Number
49
27
38
Largest Number is : 49

C Program To Find Largest of Three Numbers Using Function

Program -:

#include<stdio.h>
void larg(int, int, int);
void main()
{
  // Variable declaration
   int a,b,c;

   printf("Enter Three Number\n");
   scanf("%d %d %d",&a,&b,&c);

   //calling function to find largest number
   larg(a,b,c);
}
void larg(int a, int b, int c)
{  int larg;
     // larg among a, b and c
  if(a>b)
  {
      if(a>c)
        larg = a;
      else
        larg = c;
  }
  else
  {
      if(b>c)
        larg = b;
      else
        larg = c;
  }

  //Display Largest number
    printf("Largest Number is : %d",larg);

}

Output -:

Enter Three Nuumbers
39
33
31

Largest Number is : 39

C Program To Find Largest of Three Numbers Using Conditional Operator

Program -:

//C program to find Largest number among three numbers using Conditional operator

#include<stdio.h>
void main()
{
  // Variable declaration
   int a,b,c,larg;

   printf("Enter Three Number\n");
   scanf("%d %d %d",&a,&b,&c);

  // Larg among a, b and c
   larg = a>b?a>c?a:c:b>c?b:c;

  //Display Largest number
   printf("Largest Number Among 3 Number : %d",larg);

}

Output -:

Enter Three Nuumbers
329
323
328

Largest Number Among 3 Numbers : 329

Conclusion

In this article, we have created all the following programs -:

  • C Program to find Largest of Three numbers (Simple Way)
  • C Program to find Largest of Three numbers using function
  • C Program to find Largest of Three numbers using conditional operator

If you have difficulty to understanding any program or have any doubts or questions, then tell me in the comment below.

Jeetu Sahu is A Web Developer | Computer Engineer | Passionate about Coding, Competitive Programming, and Blogging

Leave a Comment