C Program To Find The Largest Of Three Numbers

     Hey fellows! Today I got a C program on how to find the largest of three numbers using if-else statement. In this program we'll learn the use of if-else statement and logical operators to compare the numbers. So let's start...

c program to find the largest of three numbers using if-else statement
  • LOGIC : 

In this program, we'll use if-else statement to check the numbers and in it we'll compare the numbers and print the largest number. Let's go to the algorithm part...

  • ALGORITHM :
  1. Start
  2. Declare three variables to store numbers.
  3. Input the three numbers from user.
  4. In if-else statement compare a number with other two.
  5. Print the number which comes out to be largest.
  6. End.
  • CODE :
#include <stdio.h>

int main ()
{
    //Declare the variables
    int a,b,c;
    printf("Enter three numbers : ");
    //Take input from user
    scanf("%d %d %d",&a,&b,&c);

    //compare the three numbers
    //Print the largest number accordingly
    if(a>b && a>c)
    {
        printf("%d is the largest",a);
    }
    else if(b>c && b>a)
    {
        printf("%d is the largest",b);
    }
    else
    {
        printf("%d is the largest",c);
    }

    return 0;
}
  •  OUTPUT :

Enter three numbers : 81  7  12
81 is the largest

  •  CHALLENGE.4 :

Try to make a program to find if the input character is a vowel or consonant.

 

That's all for today. If you got stuck at somewhere then don't hesitate to ask.

And if you're enjoying coding then do follow and share it with your friends.

Thanks and signing off : )

Comments