C++ Menjumlah Data

#include<conio.h>
#include<iostream.h>
int data[100],n,a;

void inputdata(){
cout<<" Masukkan data : ";
cin>>n;
for(int a=0;a<n;a++){
cout<<" data ke "<<a<<" = ";
cin>>data[a];
}
}

int count(){
return n;
}

int sum(){
int sum=0;
for(int a=0;a<count();a++){
sum=sum+data[a];
   }
return sum;
}

int mean(){
return sum()/count();
}

int main(){
inputdata();
   cout<<endl;
   cout<<count()<<endl;
   cout<<sum()<<endl;
   cout<<mean()<<endl;
   getch();
}

0 Response to "C++ Menjumlah Data"

Posting Komentar