1 / 5

Struktur

Struktur. Sugeng Supriyadi, M.Kom. Structure. Struktur adalah sekumpulan variabel yang masing-masing dapat berbeda tipe,dan dikelompokkan ke dalam satu nama Variabel-variabel yang membentuk struktur dinamakan elemen struktur. Deklarasi Struktur. Struct { elemen_struktur 1;

march
Download Presentation

Struktur

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. Struktur Sugeng Supriyadi, M.Kom

  2. Structure • Struktur adalah sekumpulan variabel yang masing-masing dapat berbeda tipe,dan dikelompokkan ke dalam satu nama • Variabel-variabel yang membentuk struktur dinamakan elemen struktur

  3. Deklarasi Struktur Struct { elemen_struktur 1; elemen_struktur 2; --------- ---------- }nama_tipe_struktur; Struct nama_tipe_struktur { elemen_struktur 1; elemen_struktur 2; --------- ---------- }

  4. Contoh: #include<iostream.h> #include<conio.h> void main() { struct { char nim[8]; char nama[15]; float nilai; }mahasiswa; cout<<"Masukan NIM\t: ";cin>>mahasiswa.nim; cout<<"Masukan NAMA\t: ";cin>>mahasiswa.nama; cout<<"Masukan NILAI\t: ";cin>>mahasiswa.nilai; //tampilkanhasil cout<<"HasilInputannyaAdalah\n"; cout<<"NIM\t: "<<mahasiswa.nim<<endl; cout<<"NAMA\t: "<<mahasiswa.nama<<endl; cout<<"NILAI\t: "<<mahasiswa.nilai<<endl; getch();}

  5. StrukturDidalamStruktur #include<iostream.h> #include<conio.h> void main() { structdtmhs { char nim[8]; char nama[15]; }; structdtnil { float nil1; float nil2; }; struct { structdtmhsmhs; structdtnil nil; }nilai; cout<<"Masukan NIM\t\t: ";cin>>nilai.mhs.nim; cout<<"Masukan NAMA\t\t: ";cin>>nilai.mhs.nama; cout<<"Masukan NILAI UTS\t: ";cin>>nilai.nil.nil1; cout<<"Masukan NILAI UAS\t: ";cin>>nilai.nil.nil2; cout<<endl; //tampilkanhasil cout<<"HasilInputannyaAdalah\n"; cout<<"NIM\t\t: "<<nilai.mhs.nim<<endl; cout<<"NAMA\t\t: "<<nilai.mhs.nama<<endl; cout<<"NILAI UAS\t: "<<nilai.nil.nil1<<endl; cout<<"NILAI UAS\t: "<<nilai.nil.nil2<<endl; getch(); }

More Related