Find Greatest of Three Numbers in C

C में एक program लिखो जो User से तीन number input ले, और उसमे सबसे बड़े नंबर को print करे।

चलिये Find Greatest of Three Numbers in C program देखते हैं और समझते हैं।

Program Code

#include <stdio.h>

int main()
{
    int num1, num2, num3;

    printf("Enter three numbers: ");
    scanf("%d %d %d", &num1, &num2, &num3);

    if (num1 >= num2 && num1 >= num3)
        printf("Greatest number is: %d", num1);
    else if (num2 >= num1 && num2 >= num3)
        printf("Greatest number is: %d", num2);
    else
        printf("Greatest number is: %d", num3);

    return 0;
}

Enter three numbers: 25 60 40

Greatest number is: 60

Program Explanation

Variable Declaration

int num1, num2, num3;

यहाँ तीन integer variables declare किए गए हैं जिनमें Number Store होगा।

Taking Input from User

User से एक साथ तीन numbers input लिए जा रहें हैं।

If Condition (First Case)

यह check करता है:

अगर दोनों condition true हैं → num1 सबसे बड़ा number है।

Else If Condition (Second Case)

else if (num2 >= num1 && num2 >= num3)

अगर num1 सबसे बड़ा नहीं है, तो यह check होगा कि:

  • num2 >= num1
  • num2 >= num3

अगर else if Condition true → num2 greatest है।

Else Condition (Last Case)

else

अगर ऊपर की दोनों conditions false हैं, तो automatically num3 सबसे बड़ा होगा।

Flowchart 

find greatest of three number in c

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top