Contoh program struct dengan Array pada c++

Contoh program struct dengan Array
Contoh program struct dengan Array pada c++, Nah lo nongol lagi dah, Biggrin kalau yang sebelumnya kan contoh program struct dengan fungsi.. sekarang saya kasih dah contoh program dengan array, Contoh program struct dengan Array pada c++. apa sih pengertian array? juga udah saya siapkn tinggal baca aja disitu. langsung dah nih contoh program struct dengan array menggunakan c+
#include<stdio.h>
#include<conio.h>
#include<iostream.h>
void main(){
     int i;
     struct{
     char nim[5];
     char nama[15];
     float nilai;
} mhs[5];

clrscr();
   for(i=1; i<=2; i++){
   cout<<"masukan NIM = ";
   cin>>mhs[i].nim;
   cout<<"masukan Nama = ";
   cin>>mhs[i].nama;
   cout<<"masukan Nilai Akhir = ";
   cin>>mhs[i].nilai;
}
cout<<endl;
cout<<"data Mahasiswa"<<endl;

for(i=1; i<=2; i++){
    cout<<"Data Ke - "<<i<<endl;
    cout<<"NIM = "<<mhs
    [i].nim<<endl;
    cout<<"Nama = "<<mhs
    [i].nama<<endl;
cout<<"Nilai Akhir = "<<mhs
    [i].nilai<<endl;
    cout<<endl;
}
getch();
}


Share on Google Plus

About Admin

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment

5 comments: