Greatest of Three Numbers in C language

  • Initially, we will declare four integer variables such as a,b,c, and another integer variable “big”.
  • Now, we will assume ‘a’ is biggest than ‘b’ and ‘c’ and stored to the resultant variable ‘big’.
  • Now, ‘b’ is compared with the resultant variable ‘big’. If ‘b’ is greater than ‘big’ then ‘b’ will be stored to the resultant variable ‘big’.
  • Now, ‘c’ is compared with the resultant variable ‘big’. If ‘c’ is greater than ‘big’ then ‘c’ will be stored to the resultant variable ‘big’.

Below is an example to find greatest of three numbers in C language

#include <stdio.h> 
main()
{
int a,b,c,big;
printf("\n Enter three numbers: ");
scanf("%d %d %d",&a,&b,&c);
//Here we will assume 'a' is biggest than 'b' and 'c'
big = a;
if(b>big)
{
big = b;
}
if(c>big)
{
big = c;
}
printf("\n The greatest of three numbers is: %d",big);
}

--

--

Hi, This is Biplab and I am web developer well versed in PHP and other open source technologies. I am here to share my experience with the community.

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Bipsmedium

Bipsmedium

Hi, This is Biplab and I am web developer well versed in PHP and other open source technologies. I am here to share my experience with the community.