Saturday, June 18, 2016

C Program Code:Find Largest of Three Numbers

C Program Code:

#include<stdio.h>
int main()
{
    int firstNumber, secondNumber, thirdNumber, largest;
    printf("Find Largest of Three Numbers in C \n");
    printf("Enter First Number  : ");
    scanf("%d", &firstNumber);
    printf("Enter Second Number : ");
    scanf("%d", &secondNumber);
    printf("Enter Third Number  : ");
    scanf("%d", &thirdNumber);
    largest = firstNumber;
    if (secondNumber > largest)
    {
        largest = secondNumber;
    }
    if (thirdNumber > largest)
    {
        largest = thirdNumber;
    }
    printf("Largest Number is %d \n", largest);
    printf("Press enter to continue...\n");
    fflush(stdin);
    getchar();
    return 0;
}

Find Largest of Three Numbers C using if else Output Screenshot