Contoh Listing Program C++ Nilai Maksimal dan Nilai Minimal



//---------------------------------------------------------------------------

#include<vcl.h>
#include<conio.h>
#include<stdio.h>
int main()
{ int a,b,c,d;
float rata,jml;
printf("masukkan angka pertama: ");scanf("%d",&a);
printf("masukkan angka kedua :");scanf("%d",&b);
printf("masukkan angka ketiga :");scanf("%d",&c);
printf("masukkan angka keempat :");scanf("%d",&d);
printf("\n\nnilai maksimalnya adalah :");
if(a>=b &&a>=c&& a>=d)printf("%d",a);
else if(b>=a && b>=c && b>=d)printf("%d",b);
else if(c>=a &&c>=b&& c>=d)printf("%d",c);
else printf("%i",d);

printf("\n\nnilai minimalya adalah :");
if(a<=b &&a<=c&& a<=d)printf("%d",a);
else if(b<=a && b<=c && b<=d)printf("%d",b);
else if(c<=a && c<=b && c<=d)printf("%d",c);
else printf("%i",d);

printf("\n\nnilai rata-ratanya adalah :");{
jml=a+b+c+d;
rata=jml/4;
printf("%5.1f",rata);}

getch();

        return 0;
}
//---------------------------------------------------------------------------

Previous
Next Post »
Thanks for your comment

Random Posts