Quick actions

cmd+k|ctrl+k

Navigation

Languages

Contoh 7_1 Algortitma Dan Struktur Data

Snippet info

Language

Cpp

Visibility

public

Author

fadhlanr

Created

2025-11-22T04:55:53.843676Z

Updated

2025-12-13T01:58:38.160936Z

#include <iostream>
using namespace std;

void judul() {
    puts("=====================================");
    puts("\tContoh Array Dimensi 1");
    puts("=====================================");
}

int main() {
    judul();
    int i;
    float harga[5];
    harga[0] = 1000;
    harga[1] = 2000;
    harga[2] = 3000;
    harga[3] = 4000;
    harga[4] = 5000;

    printf("Variable harga 1 adalah %.0f\n", harga[1]);
    printf("Variable harga 3 adalah %.0f\n", harga[3]);

    cout << "\n\n";

    puts("Nilai dari seluruh variable adalah:");
    for(i = 0; i < 5; i++) 
    {
        printf("Variable harga %d adalah %.0f\n", i, harga[i]);
    }

    puts("=====================================");
    cout << "Nama : M Fadhlan Robbi" << endl;
    cout << "Email: [email protected]" << endl;

    return 0;
}
//Nama  : M Fadhlan Robbi
//NIM   :3420240001
INFO