#include <stdio.h>
#include <conio.h>
int main(void)
{
int data[150];
int i, j, tukar, n;
float jumlah = 0, ratarata;
printf("banyak data ? ");
scanf("%d", &n);
clrscr();
for(i=0; i<n; i++)
{
printf("masukkan data ke-%d ? ",i+1);
scanf("%d",&data[i]);
clrscr();
}
printf("data yang anda masukkan\n\n");
for(i=0; i<n; i++)
{
printf("%d ",data[i]);
jumlah += data[i];
}
for(j=0; j<n; j++)
{
for(i=0; i<n; i++)
{
if(data[i] > data[i+1])
{
tukar = data[i];
data[i] = data[i+1];
data[i+1] = tukar;
}
}
}
printf("\n\ndata minimum -> %d\n\n", data[0]);
printf("data maksimum -> %d\n\n", data[n-1]);
ratarata = jumlah / n;
printf("data rata-rata -> %f", ratarata);
getch();
return 0;
}
Tidak ada komentar:
Posting Komentar