C++ Mencari Nilai Rata - Rata

#include <iostream.h>
#include <conio.h>
main(){
float n[1],jum=0,rata;
int a,i;
   cout<<" *---------------------------*\n";
   cout<<" # MENCARI NILAI RATA - RATA #\n";
   cout<<" *---------------------------*\n\n";
   cout<<" Masukkan Jumlah data : ";
   cin>>i;
   for(a=1;a<=i;a++){
    cout<<"\nMasukkan nilai ke "<<a<<": ";
    cin>>n[a];
    jum=jum+n[a];
   }
   rata=jum/i;
   cout<<endl;
   cout<<" Nilai rata - rata : "<<rata;
   getch();
   return 0;
}

0 Response to "C++ Mencari Nilai Rata - Rata"

Posting Komentar