#include <iostream>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int main() {
float i,jumlah,x,rata;
i=1;
jumlah=0;
cout<<"******_menghitung rata-rata dari integer positif_******"<<endl;
cout<<endl;
cout<<"masukan nilai : ";cin>>x;
cout<<endl;
while (x>0){
jumlah+=x;
cout<<"data ke : "<<i+1<<" ";cin>>x;
cout<<endl;
i++;
}
rata=jumlah/(i-1);
cout<<"rata-rata : "<<rata;
return 0;
}
Tidak ada komentar:
Posting Komentar