I remember one day in the year 2006, my cousin Senthil Kumaran asked me to write a program in C language to print *(stars) vertically like below:
Ha ha, really I didn't even try or know actually. Later I learned few programming languages of my own and got help from others including Senthil dha.
I have a little free time these days and was thinking to do something useful. So started writing string manipulating programs using c#. Today, this vertical star striked in my mind. As I don't have Turbo C or C++, I did it in Microsoft C#.
Below is the code for printing the *s vertically based on the numbers entered in the textbox:
Output:
My output has '+' instead of ' ' (space), because I've used asp.net label to display the stars and it does not accepts multiple spaces.However, it supports in c# console application.
My trick was to print spaces before printing * in each line till the count. For example, if the number entered is 5, the first line would print 4 spaces and then a *, the next line would print 3 spaces and then 2 *s and so on.
Console application code:
Console application output:
I'm not sure about other ways of printing. If anybody knows, then let me know.