Quick actions

cmd+k|ctrl+k

Navigation

Languages

Algoritma 12.1

Snippet info

Language

Cpp

Visibility

public

Author

laodeiyan21

Created

2025-12-27T05:08:55.501117Z

Updated

2025-12-27T05:10:26.777699Z

#include <iostream>
#include <stdio.h>
using namespace std;
/*
    Nama : la ode ian
    Nim  : 3420210002
    prodi: Informatika
*/

// DEKLARASI FUNGSI
// return value tanpa parameter
float getPPN();

// return value dengan parameter
float hitungSubtotal(int harga, int jumlah);

// tidak return value tanpa parameter
void header();

// tidak return value dengan parameter
void tampilHasil(string judul, int harga, int jumlah);


void garis(int awal) {
    for (int i = 0; i <= awal; i++) {
        printf("=");
    }
    printf("\n");
}

void judul() {
    garis(40);
    puts("Contoh Program Struct");
    garis(40);
}

string cek_nama() {
    string nama = "La ode ian";
    return nama;
}

string cek_email() {
    string email = "[email protected]";
    return email;
}

void author() {
    string get_nama = cek_nama();
    cout << "Nama  : " << get_nama << endl;

    string get_email = cek_email();
    cout << "Email : " << get_email << endl;
}

int main() {
    judul();

    /*
      By giving a name to the structure, you can treat it as a data type.
      This means that you can create variables with this structure anywhere
      in the program at any time.
      To create a named structure, put the name of the structure right
      after the struct keyword.
    */

    struct data {
        char nama[15];
        char nim[10];
        int nilai;
    };

    data mahasiswa;

    cout << "Masukan Nama  : <input> ";
    cin >> mahasiswa.nama;
    cout << endl;

    cout << "NIM           : <input> ";
    cin >> mahasiswa.nim;
    cout << endl;

    cout << "Nilai Total   : <input> ";
    cin >> mahasiswa.nilai;
    cout << endl;

    garis(40);
    cout << "Data Mahasiswa" << endl;
    garis(40);

    cout << "Nama Mahasiswa : " << mahasiswa.nama << endl;
    cout << "NIM            : " << mahasiswa.nim << endl;
    cout << "Nilai Total    : " << mahasiswa.nilai << endl;
    garis(40);
    author();

    return 0;
}
INFO