Selamat Datang Di Blogg Saya

Selasa, 10 Januari 2012

program mencari rata-rata

#include <iostream.h>
#include <math.h>
main()
{
int N,L,Y;
char nama[10][30];
float X[25],Rata,Total=0,Xi_rata=0, SD;
cout<<"masukan inputan :";
cin>>N;



for(Y=0;Y<N;Y++)
{
cout<<"NAMA"<<(Y+1)<<":";
cin>>nama[Y];
}
for(L=0;L<N;L++)
{
cout<<"Nilai Nama Ke"<<(L+1)<<":";
cin>>X[L];
Total=Total+X[L];
}
for(L=0;L<N;L++)
Rata=Total/N;

for(L=0;L<N;L++)
{
Xi_rata+=((X[L]*Rata)*(X[L]*Rata));
}

SD=sqrt(Xi_rata/N);

cout<<endl;

cout<< "no \tNAMA \t\tNILAI "<<endl;
for(L = 0; L<N; L++){
cout<< L+1 <<" \t" << nama[L] << " \t\t"<< X[L]<<endl;
}
cout<<endl;
cout<<endl;
cout<<"Jumlah Data Inputan="<<N<<endl;
cout<<"Total Nilai="<< Total<<endl;
cout<<"Rata-rata Nilai="<<Rata<<endl;
cout<<"Deviasi Standart="<<SD<<endl;

    system("PAUSE");
    return EXIT_SUCCESS;
}

0 comments:

Posting Komentar