This problem again presents us with the task of creating a diagonal, but this time, the diagonal rises from left to right, rather than leaning from left to right.
In this diagonal, we notice an interesting fact, after observing the co-ordinates of stars made up of row and column numbers. The co-ordinates of stars sum up to n+1 where "n" is the input value.
So, like our previous program to print a diagonal (Pattern 7), we just need to change the if condition from (i == j) to print the star to (i + j == n + 1).
The programming implementation will be as follows:
The program yields the following output for input value n = 5:
Again, we could run this program a little faster, by including a break statement to conclude the "printing loop" after we have printed the required star on the line.