TUGAS ANALISA 4.4



#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 n=1,jumlah=0,x;
    float rata;
    cout<<"menghitung Rata - Rata Integer Positif \n";
    cout<<"Masukkan jumlah data ="; cin>>n;
 
    for(int i=1; i<=n; i++){
    cout<<"data ke-"<<i<<" =";cin>>x;
    jumlah=jumlah+x;
    }
    rata=(float)jumlah/n;
    cout<<"rata-rata="<<rata;
return 0;
}

Program Raptornya

Comments