0% found this document useful (0 votes)
12 views2 pages

C++ Nested Loops Example Code

The document contains two C++ programs. The first program prints a decreasing sequence of numbers starting from 15, while the second program generates a series of numbers starting from 32, incrementing by 2 in each row, and decreasing the starting number by 10 for each subsequent row. Both programs utilize nested loops for their respective outputs.
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)
12 views2 pages

C++ Nested Loops Example Code

The document contains two C++ programs. The first program prints a decreasing sequence of numbers starting from 15, while the second program generates a series of numbers starting from 32, incrementing by 2 in each row, and decreasing the starting number by 10 for each subsequent row. Both programs utilize nested loops for their respective outputs.
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

Soal nomor 1

#include <iostream>

using namespace std;

int main() {

int n = 15;

int r = 5;

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

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

cout << n << " ";

n--;

cout << "\n";

r--;

return 0;

}
Soal nomor 2

#include <iostream>

using namespace std;

int main() {

int num = 32;

int r = 4 ;

int c = 5 ;

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

int s = num;

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

cout << s << " ";

s += 2;

cout << "\n";

num -= 10;

return 0;

You might also like