C++ program to print a hollow square or rectangle star pattern

C++ program to print a hollow square or rectangle star pattern.

Flowchart to print hollow square or rectangle star pattern

Flowchart to print hollow square or rectangle star pattern in C++

C++ Source Code to print hollow square or rectangle star pattern

Output

print hollow square or rectangle star pattern in C++

loop If condition Output
    true false
i=1

j=1

If(i==1||i==n||j==1||j==n)        *          –
i=1

j=2

If(i==1||i==n||j==1||j==n)        *          –
i=1

j=3

If(i==1||i==n||j—1||j==n)        *          –
i=2

j=1

If(i=1||i==n||j==1||j==n)        *          –
i=2

j=2

If(i==1||i==n||j==1||j==n)         –          *
I=2

J=3

If(i==1||i==n||j==1||j==n)        *          –
I=3

J=1

If(i==1||i==n||j==1||j==n)        *          –
i=3

j=2

If(i==1||i==n||j==1||j==n)        *         –
I=3

J=3

If(i==1||i==n||j==1||j==n)         *         –

Excercise

Find the possible mistakes in the following Shamil’s Flow Table of the program to print a hollow square or rectangle star pattern.

Loop If condition                                    What lines will executed Actual work to do
Outer Inner
1 1 T 1,2,3,4,,5,6,7,8,

9,10,11,12,13,14,

15,16,17,22,23,24

*
F 1,2,3,4,5,6,7,8,9,

10,11,12,13,14,

18,19,20,21,22,23,24

2,3 T 1,2,3,4,5,6,7,8,

9,10,11,12,13,

14,15,16,17,22,

23,24,{12,13,14,

15,16,17,22,23,24}2

 

 

***
F 1,2,3,4,5,6,7,8,

9,10,11,12,13,

14,18,19,20,21,

22,23,24,

 

{12,13,14,18,19,

20,21,22,23,24}2

 

 

2 1 T 1,2,3,4,5,6,7,8,9,

10,11,12,13,14,

15,16,17,22,23,

24,{12,13,14,15,

16,17,22,23,24}2,

25,26,27

,28,9,10,11,12,

13,14, 15,16,

17,22,23,24

 ***

*

F 1,2,3,4,5,6,7,8,9,

10,11,12,13,14,

18,19,20,21,22,

23,24,{12,13,14,

18,19,20,21,22,

23,24}2,25,26,

27,9,10,11,12,

13,14,18,19,20,

21,22,23,24

2 T 1,2,3,4,5,6,7,8,

9,10,11,12,13,

14,15,16,17,

22,23,24,{12,13,

14,15,16,17,22,

23,24}2,25,26,

27,9,10,11,12,

13,14,15,16,17,

22,23,24,12,13,

14,18,19,20,21,

22,23,24

***

*-

F 1,2,3,4,5,6,7,8,9,

10,11,12,13,14,

18,19,20,21,22,

23,24,{12,13,14,

18,19,20,21,22,

23,24}2,25,26,27,

9,10,11,12,13,14,

18,19,20,21,22,

23,24,12,13,14,

15,16,17,22,23,24

3 T 1,2,3,4,5,6,7,8,9,

10,11,12,13,14,

15,16,17,22,23,

24,{12,13,14,15,

16,17,22,23,24}2,

25,26,27,9,10,11,

12,13,14,15,16,

17,22,23,24,12,13,

14,18,19,20,21,

22,23,24,12,13,

14,15,16,17,22,23,24

***

*-*

F 1,2,3,4,5,6,7,8,9,

10,11,12,13,14,

18,19,20,21,22,

23,24,{12,13,14,

18,19,20,21,22,

23,24}2,25,26,27,

9,10,11,12,13,

14,18,19,20,21,

22,23,24,12,13,

14,15,16,17,22,23,

24,12,13,14,18,19,

20,21,22,23,24

3 1 T 1,2,3,4,5,6,,7,8,9,

10,11,12,13,14,

15,16,17,22,23,24,

{12,13,14,15,16,

17,22,23,24}2,25,

26,27,9,10,11,12

,13,14,15,16,17,

22,23,24,12,13,

14,18,19,20,21,22,

23,24,12,13,14,

15,16,17,22,23,

24,25,26,27,28,9,

10,11,12,13,14,

15,16,17,22,23,24

***

*-*

*

F 1,2,3,4,,5,6,7,8,9,

10,11,12,13,14,18,

19,20,21,22,23,

24,{12,13,14,18,19,

20,21,22,23,24}2,

25,26,27,9,10,11,

12,13,14,18,19,20,

21,22,23,24,12,13,

14,15,16,17,22,23,

24,12,13,14,18,19,

20,21,22,23,24,25,

26,27,28,9,10,11,

12,13,14,18,19,20,

21,22,23,24

2,3 T 1,2,3,4,5,6,7,8,9,10,

11,12,13,14,15,17,

22,23,24,{12,13,

14,15,16,17,22,

23,24}2,25,26,27,

9,10,11,12,13,14,

15,16,17,22,23,24,

12,13,14,18,19,20,

21,22,23,24,12,13,

14,15,16,17,22,23,

24,25,26,27,28,9,

10,11,12,13,14,15,

16,17,22,23,24,

{12,13,14,15,16,17,

22,23,24}2,25,26,27,28

 

 

 

***

*-*

***

F 1,2,3,4,,5,6,7,8,9,

10,11,12,13,14,18,

19,20,21,22,23,24,

{12,13,14,18,19,20,

21,22,23,24}2,25,

26,27,9,10,11,12,

13,14,18,19,20,21,

22,23,24,12,13,14,

15,16,17,22,23,24,

12,13,14,18,19,20,

21,22,23,24,25,26,

27,28,9,10,11,12,

13,14,18,19,20,21,

22,23,24,{12,13,14,

18,19,20,21,22,

23,24}2,25,26,27,28

 

 

 

 

Latest posts by Prof. Fazal Rehman Shamil (see all)

Buy advertisement space on T4Tutorials

For more details email [email protected]