Tuesday, September 2, 2014

membuat program input nilai dan mengurutkannya

#include<iostream.h>

#include<conio.h>
int nakhir[100], x, total, min=100, max=0, nim[12], ratarata;
char nama[12] [30], jawab;
void main()
{do
                {
                x++;
                cout<<"Data ke "<<x<<":"<<endl;
                cout<<"Nama : ";
                cin>>nama[x];
                cout<<"NIM : ";
                cin>>nim[x];
                cout<<"nilai akhir : ";
                cin>>nakhir[x];
                ratarata += nakhir[x];
                if(max<nakhir[x])
                                max = nakhir[x];
                if(min>nakhir[x])
                                min = nakhir[x];
                cout<<"Masih ada data [y/t]: ";
                cin>>jawab;
                cout<<"------------------------------------\n";
                } while(jawab=='y');
                clrscr();
                                cout<<"NIM  | Nama    | Nilai akhir\n";
                for( int i=1;i<=x;i++)
                {
                                cout<<nim[i]<<"  |  "<<nama[i]<<"   |    "<<nakhir[i];
                                cout<<endl;
                }
                cout<<"------------------------------------\n";
                total = ratarata/x;
                cout<<"Nilai rata-rata : "<<total<<endl;
                cout<<"Nilai tertinggi : "<<max<<endl;
                cout<<"Nilai terendah  : "<<min<<endl;
}



0 komentar

Post a Comment

komentar anda sangat berharga