C++ Pattern Printing: Pyramid and Inverted Triangle Patterns

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/9

flashcard set

Earn XP

Description and Tags

Vocabulary flashcards covering C++ nested loop pattern printing algorithms, including palindromic number pyramids, inverted character triangles, and inverted number triangles.

10 Terms

1
New cards
<p>Palindromic Number Pyramid Pattern</p>

Palindromic Number Pyramid Pattern

A pattern for n=4n = 4 that prints n−i−1n - i - 1 leading spaces, followed by ascending numbers from 11 to i+1i + 1, and then descending numbers from ii down to 11, producing the rows 1, 121, 12321, and 1234321.

2
New cards

Pyramid Leading Spaces Loop

The inner loop construct for(int j=0; j<n-i-1; j++) which outputs n−i−1n - i - 1 space characters to properly indent each line ii of the pyramid.

3
New cards

First Number Half Loop (nums1)

The inner loop for(int j=1; j<=i+1; j++) in the pyramid pattern that prints increasing integers starting at 11 up to i+1i + 1.

4
New cards

Second Number Half Loop (nums2)

The inner loop for(int j=i; j>0; j--) in the pyramid pattern that prints decreasing integers starting at ii down to 11.

5
New cards
<p>Inverted Character Triangle Pattern</p>

Inverted Character Triangle Pattern

A pattern that prints ii leading spaces followed by 4−i4 - i occurrences of an uppercase character per row, incrementing from 'A' to 'D' across four rows.

6
New cards

Inverted Triangle Space Loop

The inner loop for(int j=0; j<i; j++) used in inverted triangle patterns to print ii leading spaces on row ii, creating an increasing indent from top to bottom.

7
New cards

Row Element Count Formula (4−i4 - i)

The termination condition expression j < 4 - i (or n−in - i) determining how many numbers or characters are printed on row index ii, decreasing from 44 elements down to 11.

8
New cards

Character Increment Statement (ch++)

The operation placed at the end of the outer loop body that advances the ASCII character ch to the subsequent character in the alphabet (e.g., from 'A' to 'B') after completing a row.

9
New cards
<p>Inverted Number Triangle Pattern</p>

Inverted Number Triangle Pattern

An inverted triangle pattern where row ii displays ii leading spaces followed by 4−i4 - i copies of the value i+1i + 1, generating the rows 1111, 222, 33, and 4.

10
New cards

Row Value Expression (i+1i + 1)

The output expression cout << i+1; in the inverted number triangle pattern that prints the row's 1-based index repeatedly across that row.