0% found this document useful (0 votes)
16 views

Program C++

The document contains details about a student named Sonia Andiska from class TI-B who is taking the Structured Data course. It includes 3 C++ programs that print matrices with different logic. The first program prints a 6x6 matrix where the elements are the product or sum of the row and column indexes depending on if row is less than or equal to column. The second prints a 5x5 matrix with 1's below the diagonal and 0's above. The third prints another 6x6 matrix with the product if the row and column indexes are equal, and their sum otherwise.

Uploaded by

sonia.andiska
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

Program C++

The document contains details about a student named Sonia Andiska from class TI-B who is taking the Structured Data course. It includes 3 C++ programs that print matrices with different logic. The first program prints a 6x6 matrix where the elements are the product or sum of the row and column indexes depending on if row is less than or equal to column. The second prints a 5x5 matrix with 1's below the diagonal and 0's above. The third prints another 6x6 matrix with the product if the row and column indexes are equal, and their sum otherwise.

Uploaded by

sonia.andiska
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

NAMA : SONIA ANDISKA

NIM : C2255201061

KELAS : TI-B

MATA KULIAH : STRUKTUR DATA

No.1 Program Mencetak Matriks

#include <iostream>

#include <iomanip>

using namespace std;

int main() {

int soal3[6][6];

for (int z0 = 1; z0 < 6; ++z0) {

cout << "|";

for (int a0 = 0; a0 < 6; ++a0) {

soal3[z0][a0] = z0 <= a0 ? z0 * a0 - 1 + 0.75: z0 + a0;

cout << setw(4) << soal3[z0][a0];

cout << "|\n";

return 0;

Hasil
No.2 Program Mencetak Matriks

#include <iostream>

#include <iomanip>

using namespace std;

int main() {

cout << "=================\n";

int soal2[5][5];

for (int i = 0; i < 5; i++){

cout << "|";

for (int j = 0; j < 5; j++){

soal2[i][j] = (i <= j) ? 1 : 0;

cout << setw(3) << soal2[i][j];

cout << "|\n";

cout << "=================\n";

return 0;

Hasil
No.3 Program Mencetak Matriks

#include <iostream>

#include <iomanip>

using namespace std;

int main() {

int soal3[6][6];

for (int b0 = 1; b0 < 6; ++b0) {

cout << "|";

for (int a0 = 1; a0 < 6; ++a0) {

soal3[b0][a0] = b0 == a0 ? b0 * a0 : b0 + a0;

cout << setw(4) << soal3[b0][a0];

cout << "|\n";

return 0;

Hasil

You might also like