Kasus 6.1

Salam Alpro !!!

#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,i;
 float num[10], sum, average;
 cout<<"\t\tJumlah dan Rata Rata\n\n";
 cout<<" Masukan nilai n : ";
 cin>>n;
 for(i=1;i<=n;++i){
  cout<<endl<<i+0<<" Masukan data : ";
  cin>>num[i];
  sum+=num[i];
  
 }
 cout<<endl<<"Jumlah = "<<sum;
 average=sum/n;
 cout<<endl<<"Rata rata = "<<average;
 return 0;
}

Output :



Share this

Related Posts

Previous
Next Post »