C Programming - Program Mencari Nilai Maximum dan Minimum

Posted by Posted by batercusblack On 2:56 PM


#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;
}

suka dengan artikel ini? klik disini

0 comments

Post a Comment