Codingan Array 1 Dimensi pada C++

Assalamu’alaikum warahmaullahi wabarokatuh

Nih ada codingan buat array 1 dimensi, mav tidak disertakan penjelasannya …

Array 1 Dimensi

#include
#include
using namespace std;
int main()
{
float nilai[7];
float jumlah, rata2;
cout<<"———————————————-"<<endl;
cout<<"***Program Menghitung Nilai Rata – rata***"<<endl;
cout<<"———————————————-"<<endl;
cout<<"—————Penjelasan Program————-"<<endl;
cout<<"Masukkan 5 buah angka dan anda akan mengetahui"<<endl;
cout<<"———————————————-"<<endl;
cout<<endl;
for(int i=0;i<5;i++)
{
cout<<"Masukkan nilai ke "<<(i+1)<<" : "<>nilai[i];
}
jumlah = 0;
for(int a=0;a<5;a++)
{
jumlah = jumlah + nilai[a];
}
rata2 = jumlah/5;
cout<<"——————–Hasil——————–"<<endl;
cout<<"Nilai Rata – rata adalah "<<rata2<<endl;
cout<<"———————————————"<<endl;
system("PAUSE");
return 0;
}

About chandechildz

I'm the simple man Always happy everday every time every well View all posts by chandechildz

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: