Hasil Running |
/*PROGRAM DERET*/
#include <iostream.h>
#include <conio.h>
#include <math.h>
#include <iomanip.h>
#pragma argsused
int main()
{
int data[10];
int data2[10];
int i,j ,in, jum, jum2;
cout<<"MENGHITUNG JUMLAH BILANGAN DENGAN ARRAY"<<endl;
cout<<"---------------------------------------"<<endl;
cout<<"Masukkan banyaknya data bilangan (MAX 10) : ";
cin>>in;
jum = 0;
cout<<"Data bil 1"<<endl;
for (j=1; j<=in; j++)
{
cout<<"Data ke-"<<j<<" : ";
cin>> data[j];
jum = jum + data[j];
}
jum2 = 0;
cout<<""<<endl;
cout<<"Data bil 2"<<endl;
for (i=1; i<=in; i++)
{
cout<<"Data ke-"<<i<<" : ";
cin>> data2[i];
jum2 = jum2 + data2[i];
}
cout<<""<<endl;
cout<<"Jumlah bil 1 = ";
for (j=1; j<=in; j++)
{
cout<<data[j]<<" ";
}
cout<<"= "<<jum;
cout<<""<<endl;
cout<<"Jumlah bil 2 = ";
for (i=1; i<=in; i++)
{
cout<<data2[i]<<" ";
}
cout<<"= "<<jum2;
getch();
}
0 komentar:
Posting Komentar