#include <iostream>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int main(int argc, char** argv) {
int i, n, x, jumlah;
float rerata;
jumlah=0;
cout<<"Banyak Data : ";
cin>>n;
for (i=1; i<=n; i++){
cout<<"Masukan data ke "<<i<<" : ";cin>>x;
jumlah +=x;
}
rerata=(float)jumlah/n;
cout<<"Rata-rata = "<<rerata;
return 0;
}
Program raptornya
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int main(int argc, char** argv) {
int i, n, x, jumlah;
float rerata;
jumlah=0;
cout<<"Banyak Data : ";
cin>>n;
for (i=1; i<=n; i++){
cout<<"Masukan data ke "<<i<<" : ";cin>>x;
jumlah +=x;
}
rerata=(float)jumlah/n;
cout<<"Rata-rata = "<<rerata;
return 0;
}
Program raptornya
Comments
Post a Comment