Jumat, 20 April 2018

Tugas Pendahuluan Pertemuan 3 STRUCTURE


PERTEMUAN III
STRUCTURE

TUGAS PENDAHULUAN
1.      1. Apa yang dimaksud dengan structure!
2.      2. Jelaskan kelebihan sebuah program menggunakan structure!
3.      3. Buatlah contoh program sederhana menggunakan structure!
4.      4. Buatlah contoh program sederhana kombinasi array dan structure!

Jawaban
1.      1. Structure adalah pengelompokkan variabel-variabel yang bernaung dalam satu nama yang sama.
2.      2. Kelebihannya yaitu supaya mempermudah program dalam mendeklarasikan variabel dan lebih ter-struktur.
3.      3. Program sederhana menggunakan structure.
#include<iostream>
#include<cstdlib>
#include<stdio.h>
#include<conio.h>
#include<string.h>

using namespace std;
Struct movies_t
{
            char title[50];
            int year;
} mine, yours;
void printfmovie(movies_t movie);
int main ()
{
            char buffer[50];
            strcpy(mine.title, “2001 A Space Odyssey”);
            mine.year=1968;
            cout<<”Masukkan Judul Film Favorit :”;
            cin.getline(buffer,50);
            yours.year=ato1(buffer);
            cout<<”Judul film favorit yang ada :\n”;
            printfmovie(mine);
            cout<<”Judul film favorit kamu adalah :\n”;
            printfmovie(yours);
system(“PAUSE”);
}
void printfmovie(movies_t movie)
{
            cout<<movie.title;
            cout<<”(“<<movie.year<<”)\n”;
}

4.      4. Program sederhana kombinasi array dan structure.
#include<stdio.h>
#include<conio.h>
#include<iostream.h>
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();
}

Related Posts:

  • Tugas Akhir Pertemuan 4 POINTER//Nama     : Muhammad Zuhri //NIM      : 2016140614 //Kelas : 04TPLP011 //Tugas Akhir Struktur Data Pertemuan 4.cpp #include <iostream> #include <conio.h> #include <windows.h… Read More
  • Tugas Akhir Pertemuan 3 STRUCTURE//Nama     : Muhammad Zuhri //NIM      : 2016140614 //Kelas : 04TPLP011 //Tugas Akhir Struktur Data Pertemuan 3.cpp #include <iostream> #include <conio.h> #include <stdio.h&g… Read More
  • Tugas Akhir Pertemuan 5 FUNCTION//Nama     : Muhammad Zuhri //NIM      : 2016140614 //Kelas : 04TPLP011 //Tugas Akhir Struktur Data Pertemuan 5.cpp #include <iostream> #include <conio.h> #include <stdio.h&g… Read More
  • Tugas Akhir Pertemuan 8 SORTING (Lanjut 1)//Nama     : Muhammad Zuhri //NIM      : 2016140614 //Kelas : 04TPLP011 //Tugas Akhir Struktur Data Pertemuan 8.cpp #include <iostream> #include <stdio.h> #include <conio.h&g… Read More
  • Tugas Akhir Pertemuan 7 SORTING//Nama     : Muhammad Zuhri //NIM      : 2016140614 //Kelas : 04TPLP011 //Tugas Akhir Struktur Data Pertemuan 7.cpp #include <iostream> #include <conio.h> #include <stdio.h&g… Read More

0 komentar:

Posting Komentar