filmov
tv
Rectangular Star Pattern in C Programming #c #coding #code #codeblocks #java #computerscience

Показать описание
Example :
Input: N = 5
Output:
*****
*****
*****
*****
*****
Approach:
There are 4 rules for solving a pattern-based question:
We always use nested loops for printing the patterns. For the outer loop, we count the number of lines/rows and loop for them.
Next, for the inner loop, we focus on the number of columns and somehow connect them to the rows by forming a logic such that for each row we get the required number of columns to be printed.
We print the ‘*’ inside the inner loop.
Observe symmetry in the pattern or check if a pattern is a combination of two or more similar patterns.
Input: N = 5
Output:
*****
*****
*****
*****
*****
Approach:
There are 4 rules for solving a pattern-based question:
We always use nested loops for printing the patterns. For the outer loop, we count the number of lines/rows and loop for them.
Next, for the inner loop, we focus on the number of columns and somehow connect them to the rows by forming a logic such that for each row we get the required number of columns to be printed.
We print the ‘*’ inside the inner loop.
Observe symmetry in the pattern or check if a pattern is a combination of two or more similar patterns.