How to print star pattern.

What will be the solution of the given star pattern?

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

This programming is executed on DEV C++ editor. You may use any C editor to execute this programming it will be same for all editor. 

#include<stdio.h>
#include<conio.h>
int main()
{
int row,col;                                          //Data type deceleration
for(row=1;row<=5;row++)               //For rows
{
for(col=5;col>=1;col--)            // For columns
{
if(col<=row)                    //For the condition of printing star
{
printf("*");
}
else                                 //For free space
{
printf(" ");
}
}
printf("\n");                           //For new line
}

        getch();
return 0;
}

 Output:-

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

If you face any problem in executing this program then comment in comment section so I can help you.
Otherwise visit my YouTube Video. to understand the logic. All videos are in Hindi Language.

Comments

Post a Comment

Popular posts from this blog

Abundant Number in C Programming || Learning Duniya

Automorphic Number in C Programming || Learning Duniya

How to Print Given Star Pattern