Thursday, July 14, 2011

C Programming - Program Mencari Nilai Max dan Min dari Tiga Bilangan

#include <stdio.h>

int main()
{
    int a, b, c, min, max;
    printf("beri nilai a : ");
    scanf("%d", &a);
    printf("beri nilai b : ");
    scanf("%d", &b);

    printf("beri nilai c : ");
    scanf("%d", &c);

    min = (min=(a < b) ? a : b) < c ? min : c;
    max = (max=(a > b) ? a : b) > c ? max : c;

    printf("bilangan minimum : %d\n", min);
    printf("bilangan maximum : %d\n", max);

    return 0;
}

No comments:

Post a Comment