Draw The Triangle 1 Solution
Hello Friends in this article i am gone to share Hacker Rank SQL Solutions with you | Draw The Triangle 1 Solution
Also Visit: 15 Days of Learning SQL Solution
Problem
P(R) represents a pattern drawn by Julia in R rows. The following pattern represents P(5):
* * * * *
* * * *
* * *
* *
*
Write a query to print the pattern P(20).
Solution – Draw The Triangle 1
MySQL Code
SELECT REPEAT('* ', @NUMBER := @NUMBER - 1) FROM information_schema.tables, (SELECT @NUMBER:=21) t LIMIT 20
What is a star in programming ?
In any programming language, star patterns are a common pattern widely used because it helps to improve logical thinking and flow control knowledge. You must use two or three loops to create a star pattern in the C language. The number of loops depends on the pattern that you need to create. For pattern, a minimum of two is used i.e. one for a row and one for a column. The First loop is called an outer loop that shows the rows, and the second loop is called an inner loop that shows columns.
Star patterns are a series of * or any other character used to create some pattern or any geometrical shape such as – square, triangle(Pyramid), rhombus, heart etc. These patterns are often prescribed by many programming books and are best for practicing flow control statement.
Many programmers around world extremely recommended pattern problems, to enhance logical thinking capabilities. As a novice programmer you must practice these patterns to get a good hands on logical thinking and program flow control.
Disclaimer: The above Problems are generated by Hacker Rank but the Solutions are Provided by NYANDER.COM. All Hacker Rank SQL Solutions Shared only for Educational and Learning Purpose.