Friday, August 11, 2017

Create pattern with "*" like as follows using C# or CSharp. Example of For Loop !


Create pattern with "*" like as follows using C# or CSharp. Example of For Loop !

*                                              *                                                                 *
* *                                           * *                                                              * *
* * *                                        * * *                                                           * * *
                                                * * * *                                                        * * * *
                                                * * * * *                                                     * * * * *
                                                                                                                   * * * * * *


In this post you will find one sample CSharp console program which will print pattern like mentioned in the post using For Loop.

You will find same pattern solution using While Loop in my future post :

As you can see in post we need dynamic pattern so first we need to take user input to get number of cycle for this pattern output.

Once you have count you can use that count against For Loop to iterate your console output.

You will find 2 For Loop in this program. 1st For Loop is required to perform number of iteration and with this loop only we will go to new line on console.

2nd For Loop is required to perform actual print of STAR ( * ).

Please find example and output of this CSharp Program as mentioned.

Console Output :




Hope this simple program help any developers.

Please post your any questions or comments bellow on comment box. Thank You !

No comments:

Post a Comment