Kamis, 16 Oktober 2014

Fungsi Mencari Bilangan Terkecil dengan C

#include<stdio.h>
void main()
{
int a,b,c,d;
printf("Bilangan terkecil\nmasukan bilangan!\n");
getch();
printf("a = "); scanf("%d", &a);
printf("b = "); scanf("%d", &b);
printf("c = "); scanf("%d", &c);
printf("d = "); scanf("%d", &d);
printf("bilangan terkecil = %d",bil_min(a,b,c,d));
getch ();
}
int bil_min(int bil_a, int bil_b, int bil_c, int bil_d)
{
    if (bil_a<bil_b && bil_a<bil_c && bil_a<bil_d)
    return bil_a;
    else if (bil_b<bil_a && bil_b<bil_c && bil_b<bil_d)
    return bil_b;
    else if (bil_c<bil_a && bil_c<bil_b && bil_c<bil_d)
    return bil_c;
    else
    return bil_d;
}


Tidak ada komentar:

Posting Komentar