#include <iostream.h>
#include <conio.h>
int main()
{
char nama[25][30];
int nilai[25];
int jumlah_inputan;
float max, min, jumlah, total;
cout << "Masukkan Jumlah Inputan : ";
cin >> jumlah_inputan;
for(int i = 0; i < jumlah_inputan; i ++) {
cout << "Masukkan Nama \t: ";
cin >> nama[i];
cout << "Masukkan Nilai\t: ";
cin >> nilai[i];
cout << endl;
}
cout << "No \t Nama \t\t Nilai " <<endl;
for(int i = 0; i< jumlah_inputan; i++){
cout << i+1 <<" \t" << nama[i] << " \t\t "<< nilai[i]<<endl;
}
total = 0;
for(int i = 0; i< jumlah_inputan; i++) {
total = total+nilai[i];
}
jumlah = 0;
for(int i = 0; i< jumlah_inputan; i++) {
jumlah = jumlah + nilai[i];
}
max = nilai[0];
for(int i = 1; i < jumlah_inputan; i++) {
if( nilai[i] > max) {
max = nilai[i];
}
}
min = nilai[0];
for(int i = 1; i < jumlah_inputan; i++) {
if( nilai[i] < min) {
min = nilai[i];
}
}
cout << endl;
cout << endl;
cout << endl;
cout << "Jumlah Data Inputan\t: " << jumlah_inputan << endl;
cout << endl;
cout << " Total Nilai \t: " << total << endl;
cout << " Nilai Rata-Rata\t: " << jumlah/jumlah_inputan <<endl;
cout << " Nilai Maksimum \t: " << max <<endl;
cout << " Nilai Minimum \t: " << min <<endl;
cout << endl;
getch ();
return 0;
}
Subscribe to:
Post Comments
(
Atom
)
0 Response to " Input data Array Menggunakan Fungsi "
Post a Comment