Quick actions

cmd+k|ctrl+k

Navigation

Languages

TUGAS 7.1

Snippet info

Language

Cpp

Visibility

public

Author

aliprizkifirnansah

Created

2024-11-16T09:06:47.552078Z

Updated

2024-11-16T09:11:26.327948Z

#include <iostream>
#include <iomanip>

using namespace std;
// Nama : Alip Rizki Firnansah
// Nim  : (3420230040) 

int main() {
  cout << "--------------------------------------" << endl;
  // Define the variables for the table
  int no, a, b, a_a, b_b;

  // Print the table header
  cout << "No" << setw(5) << "A" << setw(5) << "B" << setw(7) << "A*A" << setw(7) << "B*B" << endl;
  cout << "--------------------------------------" << endl;

  // Iterate through the rows of the table
  for (no = 1; no <= 10; no++) {
    // Calculate the values of A and B
    a = no * 2;
    b = no * 3 + 1;

    // Calculate the values of A*A and B*B
    a_a = a * a;
    b_b = b * b;

    // Print the row of the table
    cout << setw(2) << no << setw(5) << a << setw(5) << b << setw(7) << a_a << setw(7) << b_b << endl;
  }
  cout << "--------------------------------------";
  // Print the contact information
  cout << "\nNama : Alip Rizki Firnansah" << endl;
  cout << "Email: [email protected]" << endl;

  return 0;
}
INFO