nilai maksimum, minimum, dan rata

#include
main()
{
int arr[100], i, n, max=-999, min=999, x, j, k;
float total=0, rata;
printf("Masukkan jumlah data (maks. 100) = ");
scanf("%d",&n);
for(i=0;i printf("Data ke-%d = ",i+1);
scanf("%d",&arr[i]);
}

//menentukan nilai max
for(x=0;x if (arr[x]>max){
max=arr[x];
}
}
printf("\nNilai Maksimum= %d",max);

//menentukan nilai min
for (j=0;j if (arr[j] min=arr[j];
}
}
printf("\nNilai Minimum= %d",min);

//menentukan rata2
for (k=0;k total+=arr[k];
}
printf ("\nJumlah =%2.2f",total);
rata=total/n;
printf("\nRata-rata=%2.2f",rata);

return 0;
}

0 Response to "nilai maksimum, minimum, dan rata"

Posting Komentar

asalammu'alaykum.wr.wb

powered by Blogger | WordPress by Newwpthemes | Converted by BloggerTheme