Penggunaan Array pada C++
#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
void main()
{
int bulan,tgl;
char nb[15][13] = {"","Januari","Februari","Maret","April","Mei","Juni","Juli","Agustus","September","Oktober","November","Desember"}; // array dengan 13 elemen bertipe char
int hari[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31}; // array dengan 13 elemen bertipe integer
int tot;
system ("cls");
for (bulan=1;bulan <= 12;bulan++)
{
cout << "Bulan Ke " << bulan << " : " <<nb[bulan]<<" "<<hari[bulan] <<" Hari";
cout <<endl;
}
cout<<endl;
cout<<"Masukan Bulan [1-12] : "; cin>>bulan;
cout<< "Bulan Ke " << bulan << " adalah Bulan " <<nb[bulan]<<" Memiliki "<<hari[bulan] <<" Hari";
cout<<endl;
cout<<"Masukan Tanggal Sekarang : "; cin>>tgl;
cout<<endl;
}
#include<conio.h>
#include<stdlib.h>
void main()
{
int bulan,tgl;
char nb[15][13] = {"","Januari","Februari","Maret","April","Mei","Juni","Juli","Agustus","September","Oktober","November","Desember"}; // array dengan 13 elemen bertipe char
int hari[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31}; // array dengan 13 elemen bertipe integer
int tot;
system ("cls");
for (bulan=1;bulan <= 12;bulan++)
{
cout << "Bulan Ke " << bulan << " : " <<nb[bulan]<<" "<<hari[bulan] <<" Hari";
cout <<endl;
}
cout<<endl;
cout<<"Masukan Bulan [1-12] : "; cin>>bulan;
cout<< "Bulan Ke " << bulan << " adalah Bulan " <<nb[bulan]<<" Memiliki "<<hari[bulan] <<" Hari";
cout<<endl;
cout<<"Masukan Tanggal Sekarang : "; cin>>tgl;
cout<<endl;
}
Comments
Post a Comment
Terimakasih telah berkunjung dan berkomentar disini...