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
scanf(“%d %d %d”, &num1, &num2, &num3);
User से एक साथ तीन numbers input लिए जा रहें हैं।
If Condition (First Case)
if (num1 >= num2 && num1 >= num3)
यह check करता है:
- num1 >= num2
- num1 >= num3
अगर दोनों 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
printf(“Greatest number is: %d”, num3);
अगर ऊपर की दोनों conditions false हैं, तो automatically num3 सबसे बड़ा होगा।
Flowchart

