Quick actions

cmd+k|ctrl+k

Navigation

Languages

Tugas7.1versiy

Snippet info

Language

Cpp

Visibility

public

Author

yoga-dwi-kurniawan

Created

2024-11-16T09:12:45.582322Z

Updated

2024-11-16T09:15:02.465446Z

#include <iostream>
#include <iomanip> // Untuk manipulasi format output
using namespace std;
//nama :yoga dwi kurniawan 
//nim  : 3420230019

int main() {
    // Header tabel
    cout << "---------------------------------------------" << endl;
    cout << setw(4) << "No" 
         << setw(6) << "A" 
         << setw(6) << "B" 
         << setw(8) << "A*A" 
         << setw(8) << "B*B" << endl;
    cout << "---------------------------------------------" << endl;

    // Variabel untuk nilai A dan B
    int A = 2, B = 4;

    // Perulangan untuk mengisi tabel
    for (int i = 1; i <= 10; i++) {
        // Hitung A*A dan B*B
        int AA = A * A;
        int BB = B * B;

        // Tampilkan baris tabel
        cout << setw(4) << i 
             << setw(6) << A 
             << setw(6) << B 
             << setw(8) << AA 
             << setw(8) << BB << endl;

        // Update nilai A dan B
        A += 2;
        B += 3;
    }

    // Footer tabel
    cout << "---------------------------------------------" << endl;

    // Informasi nama dan email
    cout << "Nama  : Yoga dwi kurniawan" << endl;
    cout << "Email : [email protected]" << endl;

    return 0;
}
INFO