Flowchart to print hollow square or rectangle star pattern

C++ Source Code to print hollow square or rectangle star pattern
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
#include<iostream> using namespace std; int main() { int n,i,j; cout<<"enter number of rows"; cin>>n; i=1; do { j=1; do { if(i==1||i==n||j==1||j==n) { cout<<" *"; } else { cout<<" "; } j++; } while(j<=n); cout<<"\n"; i++; } while(i<=n); } |

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 |