26 December 2011

C Program to Find Greatest of Four Number using if-elseif-else Statements

27 comments
 Program to Find Greatest of Four Number using if-elseif-else Statements






#include<stdio.h>

void main()
{
int a,b,c,d;
printf("enter the four numbers : ");
scanf("%d%d%d%d",&a,&b,&c,&d);

//if first number is greater than second number
if(a>b)
{
//if first number is greater than third number
if(a>c)
{
//if first number is greater than fourth number
if(a>d)
printf("%d is greatest",a);
else
//fourth number is greater than first number i.e fourth number is also greater than 2nd and 3rd number
printf("%d is greatest",d);
}
//if 3rd number is greater than 1st number i.e 3rd number is also greater than 2nd number
else
{
//if 3rd number is greater than 4rth number
if(c>d)
printf("%d is greatest",c);
else
//if not than 4rth is greatest
printf("%d is greatest",d);
}
}
//if 2nd is greater than 1st number
else
{
if(b>c)
{
if(b>d)
printf("%d is greatest",b);
else
printf("%d is greatest",d);
}
else
{
if(c>d)
printf("%d is greatest",c);
else
printf("%d is greatest",d);
}
}
}

If You Liked This Post Please Take a Time To Share This Post

You May Also Like...

27 comments:

  1. Replies
    1. C is considered to be the most fundamental language that needs to be studied if you are beginning with any Homework For You programming language. Many programming languages such as Python, C++, Java, etc are built with the base of the C language.

      Delete
  2. Can you do it for 5 numbers

    ReplyDelete
  3. How to find 2nd largest number out of 4 number by using conditional statements?

    ReplyDelete
  4. This is an awesome post.Really very informative and creative contents. These concept is a good way to enhance the knowledge.I like it and help me to development very well.Thank you for this brief explanation and very nice information.Well, got a good knowledge.

    Data Science training in Chennai
    Data science training in Bangalore
    Data science training in pune
    Data science online training



    Data Science Interview questions and answers
    Data Science Tutorial

    ReplyDelete
  5. I appreciate your efforts because it conveys the message of what you are trying to say. It's a great skill to make even the person who doesn't know about the subject could able to understand the subject . Your blogs are understandable and also elaborately described. I hope to read more and more interesting articles from your blog. All the best.
    Data Science training in chennai
    Data Science training in OMR
    Data Science training in chennai
    Data Science Training in Chennai
    Data Science training in Chennai
    Data Science training in anna nagar

    ReplyDelete
  6. Its really an Excellent post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog. Thanks for sharing....
    Best Devops Training in pune
    Microsoft azure training in Bangalore
    Power bi training in Chennai

    ReplyDelete
  7. Very nice post here and thanks for it .I always like and such a super contents of these post.Excellent and very cool idea and great content of different kinds of the valuable information's.
    rpa training in bangalore
    best rpa training in bangalore
    rpa training in pune | rpa course in bangalore
    rpa training in chennai

    ReplyDelete




  8. And indeed, I’m just always astounded concerning the remarkable things served by you. Some four facts on this page are undeniably the most effective I’ve had.
    software Testing Training |Best Software Training Institute in Chennai



    ReplyDelete