Contoh program array c++
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
char nama[20][10];
char npm[8][10];
char kelas[5][10];
int jml;
cout<<"Masukkan jumlah record:";
cin>>jml;
clrscr();
for(int i=0;i<=jml;i++)
{
cout<<"\n input data ke-"<< i <<":";
cout<<"\n nama ke-"<<i<<":";
cin>>nama[i];
cout<<"\n npm ke-"<<i<<":";
cin>>npm[i];
cout<<"\n kelas ke-"<<i<<":";
cin>>kelas[i];
}
for(int j=0;j<=jml;j++)
{
cout<<"\n input data ke-"<< j;
cout<<"\n nama : "<< nama [j];
cout<<"\n npm : "<< npm [j];
cout<<"\n kelas : "<< kelas [j];
cout<<"\n================================\n";
}
getch();
}
Sumber : http://dhwie85.blogspot.com/2012/04/contoh-program-array-c.html
#include<conio.h>
void main()
{
clrscr();
char nama[20][10];
char npm[8][10];
char kelas[5][10];
int jml;
cout<<"Masukkan jumlah record:";
cin>>jml;
clrscr();
for(int i=0;i<=jml;i++)
{
cout<<"\n input data ke-"<< i <<":";
cout<<"\n nama ke-"<<i<<":";
cin>>nama[i];
cout<<"\n npm ke-"<<i<<":";
cin>>npm[i];
cout<<"\n kelas ke-"<<i<<":";
cin>>kelas[i];
}
for(int j=0;j<=jml;j++)
{
cout<<"\n input data ke-"<< j;
cout<<"\n nama : "<< nama [j];
cout<<"\n npm : "<< npm [j];
cout<<"\n kelas : "<< kelas [j];
cout<<"\n================================\n";
}
getch();
}
Sumber : http://dhwie85.blogspot.com/2012/04/contoh-program-array-c.html
Tidak ada komentar:
Posting Komentar