0% found this document useful (0 votes)
5 views3 pages

Nested Loop

The document outlines a series of programming tasks for generating specific patterns using loops in C++. Each task specifies the required output format and the type of loops to be used, including solid squares, number patterns, alphabet triangles, diagonal crosses, border rectangles, and plus shapes.

Uploaded by

1250100371
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)
5 views3 pages

Nested Loop

The document outlines a series of programming tasks for generating specific patterns using loops in C++. Each task specifies the required output format and the type of loops to be used, including solid squares, number patterns, alphabet triangles, diagonal crosses, border rectangles, and plus shapes.

Uploaded by

1250100371
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

Programming Fundamentals Lab Tasks

(Loops and Nested Loops)

Instructions: Read each task carefully and write a C++ program to generate the exact output
shown. Follow the loop requirement mentioned in each task.

Task 1: Print a Solid Square of Stars

Take input n and print an n × n square using the '*' character.


Loop requirement: Use a for loop (nested for loops are allowed).
Input: n = 3
Expected Output:
***
***
***

Task 2: Print an Increasing Number Pattern

Take input n and print numbers from 1 up to the current row number.
Loop requirement: Use While nested while loops.
Input: n = 4
Expected Output:
1
12
123
1234
Task 3: Alphabet Triangle Pattern

Print a triangle where each row uses the next alphabet letter, repeated as many times as the
row number.
Loop requirement: Use nested loops. Manage spacing exactly as shown.
Expected Output:
A
B B
C C C
D D D D
E E E E E
F F F F
G G G
H H
I

Task 4: Diagonal Cross Pattern with '#'

Take input n and print '#' on both diagonals to form an X shape.


Loop requirement: Use nested loops with row/column checks for diagonals.
Input: n = 5
Expected Output:
# #
# #
#
# #
# #
Task 5: Border Rectangle Using '@'

Take input n and print an n × n hollow square using '@' on the border and spaces inside.
Loop requirement: Use nested loops and print '@' only on the boundary.
Input: n = 5
Expected Output:
@@@@@
@ @
@ @
@ @
@@@@@

Task 6: Plus Shape Using '@'

Take input n (odd recommended) and print a plus '+' shape using '@' with a vertical and
horizontal line crossing at the center.
Loop requirement: Use nested loops; print '@' when row == mid or col == mid.
Input: n = 5
Expected Output:
@
@
@@@@@
@
@

You might also like