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

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”);
}

Sponsors

LEAVE A REPLY

Please enter your comment!
Please enter your name here