#pragma argused#include<conio.h>#include<iostream.h>
int main(){int data[20];int i,x,jum,mid,rata,xyz;cout<<"PROGRAM PENJUMLAHAN DATA"<<endl;cout<<"------------------------"<<endl;cout<<endl;cout<<"Masukkan Jumlah Data (Ganjil 1-20) : ";cin>>x;for(i=1;i<=x;i++){cout<<"Data ke-"<<i<<" : " ;cin>> data[i];}cout<<endl;cout<<"Data yang tadi dimasukkan : ";jum=0;for(i=1;i<=x;i++){cout<<data[i]<<" ";jum=jum+data[i];}cout<<endl;cout<<endl;cout<<"Total Penjumlahan Data : "<<jum<<" "<<endl;rata=jum/x;cout<<"Rata-rata Data : "<<rata<<endl;mid=(x+1)/2;cout<<"Data tengah (Data ke-"<<mid<<") : "<<data[mid]<<endl;xyz=data[1]+data[x];cout<<"Data awal + Data akhir : "<<xyz<<endl;getch();}
0 comments:
Post a Comment