Quick actions

cmd+k|ctrl+k

Navigation

Languages

12 al

Snippet info

Language

Cpp

Visibility

public

Author

zackyahmadsyahputra4

Created

2025-12-27T06:00:15.428293Z

Updated

2026-01-02T23:46:13.516452Z

#include <iostream>
#include <stdio.h>
using namespace std;
// NAMA : ZACKY AHMAD S
// NIM  : 3420240009
// 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);

// not return value dengan parameter
void garis(int awal) {
    for (int i = 0; i <= awal; i++) {
        printf("=");
    }
    printf("\n");
}
// tidak return value tanpa parameter
void judul() {
    garis(40);
    puts("Contoh Program Struct");
    garis(40);
}

string cek_nama() {
    string nama = "Zacky Ahmad S";
    return nama;
}

string cek_email() {
    string email = "[email protected]";
    return email;
}
// tidak return value tanpa parameter
void author() {
    string get_nama = cek_nama();
    cout << "Nama  : " << get_nama << endl;

    string get_email = cek_email();
    cout << "Email : " << get_email << endl;
}
// return value tanpa parameter
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[25];
        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