Program C++: Program Array 1 Dimensi Input dari User Part II

Output program seperti ini:
masukkan jumlah bilangan ( max 10 ) :
masukkan bilangan ke <1~input1>
hasil dari + .... + =

Screen Shoot Program


Coding:
#include <iostream.h>
#include <conio.h>

int data[10];
int n,total;

void main()
{
cout<<"===PROGRAM INPUTAN DATA DARI USER==="<<endl;
cout<<endl;
cout<<"Masukan Jumlah Data (Max 10): ";
cin>>n;
cout<<endl;
if(n<=10)
{
for(int i=1;i<=n;i++)
{
cout<<"Masukkan data ke "<<i<< " : ";
cin>>data[i];
total=total+data[i];
}
cout<<endl;
cout<<"Data yang di Masukan: ";
for(int i=1; i<=n; i++)
{
cout<<" "<<data[i];
}
cout<<endl;
cout<<"Jumlah seluruh data: "<<total;
}
else
cout<<"Inputan Tidak Sesuai";
getch();
}

Labels: