-
-
Save corinchen/789956b1c4eba9e976ef9a296631641d to your computer and use it in GitHub Desktop.
cpp macam2 qarray statistik
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Program mencari simpangan rata-rata /Means Deviation (MD) | |
#include <iostream> | |
#include <conio.h> | |
using namespace std; | |
//fungsi untuk mencari simpangan rata-rata | |
int main(int a, char** b) | |
{ | |
int i,acak; | |
//angka meng-output jumlah yang diinput ke bawah | |
cout<<"Masukkan jumlah angka acak:\t"; | |
cin>>acak; | |
//keterangan variabel | |
float *angka=new float [acak]; | |
float *s=new float [acak]; | |
float jumlah=0,rata,M,simp_rata; | |
//looping bilangan acak | |
for(i=0;i<acak;i++) | |
{ | |
cout<<"Angka ke "<<i+1<<" : ";cin>>angka[i]; | |
jumlah+=angka[i]; | |
cout<<endl; | |
} | |
rata=jumlah/acak; | |
//looping | |
for(i=0;i<acak;i++) | |
{ | |
s[i]=rata-angka[i]; | |
if(s[i]<0) | |
{ | |
s[i]=s[i]*(-1); | |
} | |
cout<<"\n|Rata-rata - Angka| ke "<<i+1<<" : "<<s[i]; | |
M+=s[i]; | |
} | |
//membuat tabel | |
cout<<"\n---------------------------------------------------------"<<endl; | |
//menghitung simpangan rata | |
simp_rata=M/acak; | |
//menampilkan rata-rata | |
cout<<"\n\n Rata-rata\t\t\t\t:"<<rata; | |
//menampilkan simapangan rata-rata | |
cout<<"\n Simpangan Rata-rata (Mean Deviation)\t: "<<simp_rata; | |
cout<<endl; | |
cout<<"---------------------------------------------------------"<<endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment