https://i1.wp.com/eblogarithm.com/wp-content/uploads/2016/10/Star-Printing--pattern-3-Right-Side-Triangle-in-C-Programming.png?fit=640%2C360

Star Printing : pattern 3 (Right Side Triangle) in C Programming

You have to print “spaces” like the pattern 2  and print the “stars” like pattern 1. For printing “spaces” you have to use another loop before printing the “stars” and after the first loop. My code is not that good. if you have any efficient code , feel free to share.

 

Here is my code :

int m, n,z,u=5; // “u” is for taking inputs from users.
for (m = 1; m <= u; m++)
{
for (n = u-1; n >=m ; n–)
{
printf(” “);
}
for (z = 1; z <= m; z++)
{
printf(“*”);
}
printf(“\n”);
}

(Visited 115 times, 1 visits today)



There are no comments

Add yours

Leave a Reply

%d bloggers like this: