C++ program to print right angled (Right oriented) pyramid of numbers
All Answers
total answers (1)
Severity: 8192
Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated
Filename: libraries/Filtered_db.php
Line Number: 23
total answers (1)
Consider the program:
Explanation
We take the number of rows as the limit in the loop. The outer loop is for taking care of rows and the inner loop will take of the columns. In this program we need to take care of the space, as it is important, otherwise pyramid won't form correctly.
Here we initialize the value of space to i, since the number of iterations keep decreasing with the increment of i and that is what we need with successive iterations. Next we run the inner loop upto ith row, since, number of elements in the row is equal to the ith value. In that loop we print the value of k and finally, increment the k for the next iteration. For printing on next row, we print the next line in the end statement of outer loop.
And that's it, nice pattern example, Right? This was the right oriented right angled puzzle. More puzzle like this will be coming soon.
Hope you like the program. Share your thoughts below in the comments.
need an explanation for this answer? contact us directly to get an explanation for this answer