Find Largest and Smallest using global variable declaration - Devbhoomi

FREE JOB ALERT & ONLINE TUTORIALS

Hot

Post Top Ad

Monday 6 November 2017

Find Largest and Smallest using global variable declaration

#include<stdio.h>

// Global variable declaration
int a, b;

int main()
{
    printf("enter the two values to find the greatest number : ");
    scanf("%d%d", &a, &b);

    //logic to find the largest and smallest numbers
    if (a < b)
    {
        printf("\nthe largest number is : %d", b);
        printf("\nthe Smallest number is : %d", a);
    }
    else if (a == b)
    {
        printf("Both are Equal");
    }
    else
    {
        printf("\nthe largest number is : %d", a);
        printf("\nthe Smallest number is : %d", b);
    }

    return 0;
}
OUTPUT
enter the two values to find the greatest number : 66
33

the largest number is : 66
the Smallest number is : 33

No comments:

Post a Comment

Post Top Ad