To find the Maximum and Minimum values of given Three Numbers

 Program:

#include<stdio.h>
#include<conio.h>
void main()
{
    int a, b, c, max, min;
    clrscr();
    printf("Enter any 3 Numbers : ");
    scanf("%d%d%d", &a, &b, &c);
    max = a>b && a>c ? a : ( b>c ? b : c);
    min = a<b && a<c ? a : ( b<c ? b : c);
    printf("Maximum Value is : %d", max);
    printf("\n Minimum Value is : %d", min);
    getch();
}

Output:

Enter any 3 Numbers : 40    80    60
Maximum Value is : 80
Minimum Value is : 40


Next Topic        :  Comma Operator Program

No comments:

Post a Comment