#include <stdio.h>
int main()
{
float min, max, x, y;
printf("Mencari nilai max dan min dari dua buah bilangan.\n");
printf("\nInput nilai x\t: ");
scanf("%f", &x);
printf("Input nilai y\t: ");
scanf("%f", &y);
max = ((x-y)>=0) ? ((x+y)+(x-y))/2.0 : ((x+y)-(x-y))/2.0;
printf("max\t= %.3f\n", max);
min = ((x-y)<=0) ? ((x+y)+(x-y))/2.0 : ((x+y)-(x-y))/2.0;
printf("min\t= %.3f\n", min);
return 0;
}
No comments:
Post a Comment