1 / 6

STRUCT OF ARRAY

STRUCT OF ARRAY. STRUCT OF ARRAY m erupakan array yang berisi struktur Contoh variabel betipe struct biasa : struct Mahasiswa { char NIM[8]; char nama [50]; float ipk ; } mhs 1,mhs2,mhs3 ; Contoh struct of array: struct Mahasiswa { char NIM[8];

chessa
Télécharger la présentation

STRUCT OF ARRAY

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. STRUCT OF ARRAY

  2. STRUCT OF ARRAY merupakan array yang berisistruktur • Contohvariabelbetipestructbiasa: structMahasiswa { char NIM[8]; char nama[50]; float ipk; }mhs1,mhs2,mhs3; • Contohstruct of array: structMahasiswa { char NIM[8]; char nama[50]; float ipk; }mhs[3];

  3. CONTOH 1: #include <iostream.h> #include <conio.h> main(){ struct orang { char nama[30]; intumur; }; struct orang murid[5]; for(int i=0;i<=4;i++){ cout<<"masukkan data muridke"<<1+i<<"\n"; cout<<"Nama : ";cin>>murid[i].nama; cout<<"Umur : ";cin>>murid[i].umur; cout<<"\n"; clrscr(); } for(int i=0;i<=4;i++) { cout<<"Data muridke"<<1+i<<" adalah"<<"\n"; cout<<"Nama : "<<murid[i].nama<<"\n"; cout<<"Umur : "<<murid[i].umur<<"\n"; cout<<endl; } getch(); }

  4. Enumerasi • DeklarasiEnumerasi : Enumnama_enumerasi{nilai1,nilai2,…}

  5. ContohEnumerasi #include <iostream.h> #include <conio.h> void main(){ enumbulan{JAN=1,PEB,APR,MEI,JUN,JUL,AGU,SEP,OKT,NOP,DES}; bulanbulanku; bulanku=APR; cout<<"sekarangadalahbulanke "<<bulanku; getch(); }

  6. Kerjakan • Jelaskanperbedaanantaratipe data char , intdan float. • Apa yang dimaksuddenganmendefinisikanstruktur, deklarasivariabeldaninisialisasivariabel? • jelaskanbaris program berikut • char alamat[30]; • intmurid[2]={2,3}; • cin>>data; • intruang[3][3]; • struct orang murid[5]; • for(inti=0;i<7;i++) { cout<<”haha…”; } • Jelaskanperbedaanantara array 1 dimensi, array 2 dimensi , danstruktur! • Selamatmengerjakan..!!

More Related