C Programming - Program Mencari Nilai Maximum dan Minimum

| |

#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", &amp;x);
 printf("Input nilai y\t: ");
 scanf("%f", &amp;y);

 max = ((x-y)&gt;=0) ? ((x+y)+(x-y))/2.0 : ((x+y)-(x-y))/2.0;
 printf("max\t= %.3f\n", max);

 min = ((x-y)&lt;=0) ? ((x+y)+(x-y))/2.0 : ((x+y)-(x-y))/2.0;
 printf("min\t= %.3f\n", min);

 return 0;
}

Related Posts by Categories

0 komentar:

Posting Komentar