Contoh Program Array
#include<iostream.h>
#include<iomanip.h>
#include<stdio.h>
#include<conio.h>
main ()
{
int i ;
char nama [5] [20];
float nilai1 [5] , nilai2 [5];
for (i=1 ; i<=2 ; i++)
{
cout<<"Data ke- "<<i<<endl;
cout<<"Nama : ";cin>>nama[i];
cout<<"Nilai 1 : ";cin>>nilai1[i];
cout<<"Nilai 2 : ";cin>>nilai2[i];
}
for (i=1 ; i<=2 ; i++)
{
cout<<"\n";
cout<<"Data ke-"<<i<<endl;
cout<<"Nama : "<<nama[i]<<"\n";
cout<<"Nilai 1: "<<nilai1[i]<<"\n";
cout<<"Nilai 2: "<<nilai2[i]<<"\n";
}
}
0 komentar:
Posting Komentar