[c++]Menentukan nilai minimum atau maksimum

July 20, 2007

 

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <conio.h>main()
{int awal, akhir, i,nx, bilangan[10], dummy;

printf(“Masukkan nilai awal : “);scanf(“%d”,&awal);
printf(“Masukkan nilai akhir : “);scanf(“%d”,&akhir);
printf(“Jumlah bilangan yang mau dimasukkan (maksimal 10) : “);scanf(“%d”,&nx);
printf(“===========================================”);

for(i=1; i<=nx;i++){

printf(“Masukkan bilangan ke-%d : “,i);scanf(“%d”,&bilangan[i]);

}

//nilai maksimum
dummy=awal; //kalo mau nyari nilai minimum awal diganti akhir;
for(i=1; i<=nx;i++){

if (bilangan[i]>dummy) dummy=bilangan[i]; //kalo nyari nilai minimum tanda > diganti <

}

printf(“Nilai maksimum : %d”, dummy);

}

Hello world!

July 18, 2007

Welcome to WordPress.com. This is your first post. Edit or delete it and start blogging!


Follow

Get every new post delivered to your Inbox.