Bifalgorithm post

Did you know if I take a number equal to 5 and write nested for loops like this and add a print statement to print a star with an end statement like this? After we run this, we get 25 stars printed on a single line. And after adding an empty print statement to move each output to a new line and run it again, we will get a square pattern printed like this. Now, if we add a condition where we say if i is equal to 0 or i is equal to n minus 1 or j is equal to 0 or j is equal to n minus 1 then print a star else print a space. When we will run this again we get a hollow square pattern like this. Don't forget to like and comment if this helped. Check my page Pi Code Dev and follow for more.

Did you know if I take a number equal to 5 and write nested for loops like this and add a print statement to print a star with an end statement like this? Afte…

Ideas in this flowchart

  • Printing Patterns with Nested Loops
  • Initial Star Printing
  • Nested For Loops
  • Print Statement
  • Output: 25 Stars in a Line
  • Square Pattern Printing
  • Add Empty Print Statement
  • Output: Square Pattern
  • Hollow Square Pattern
  • Add Condition
  • Condition: i=0, i=n-1, j=0, j=n-1
  • Print Star
  • Else Print Space
  • Output: Hollow Square Pattern
  • Engagement
  • Like and Comment
  • Follow Pi Code Dev
Feed/

Did you know if I take a number equal to 5 and write nested for loops like this and add a print statement to print a star with an end statement like this? After we run this, we get 25 stars printed on a single line. And after adding an empty print statement to move each output to a new line and run it again, we will get a square pattern printed like this. Now, if we add a condition where we say if i is equal to 0 or i is equal to n minus 1 or j is equal to 0 or j is equal to n minus 1 then print a star else print a space. When we will run this again we get a hollow square pattern like this. Don't forget to like and comment if this helped. Check my page Pi Code Dev and follow for more.

"Did you know if I take a number equal to 5 and write nested for loops"

👍
0
0 comments0 shares

Sign in to view and post comments.