Printing Various Patterns using

 #include <stdio.h>

void box (char c)

{

  c= '*';

  for(int i=1;i<=5;i++)

    {

      for(int j=1;j<=5;j++)

      {

        printf("%c\t",c);

      }

      printf("\n");

    }

}

void right_angled(char c)

{

  c='*';

  for(int i=1;i<=5;i++)

    {

      for(int j=1;j<=i;j++)

      {

        printf("%c\t",c);

      }

      printf("\n");

    }

}

void right_angle_digit(int j)

{

  for(int i=1;i<=5;i++)

    {

      for(int j=1;j<=i;j++)

      {

        printf("%d\t",j);

      }

      printf("\n");

    }

}

void right_angle_star_rev(char c)

{

  c='*';

  for(int i = 1;i<=5;i++)

    {

      for (int j=5;j>i;j--)

      {

        printf(" ");

      }

      for(int k=1;k<=i;k++)

        {

          printf("%c ",c);

        }

      printf("\n");

    }

}

  void star_pyramid(char c)

  {

  c='*';

    for(int i=1;i<=5;i++)

      {

        for(int j=5;j>i;j--)

          {

            printf(" ");

          }

        for(int k=1;k<=i;k++)

          {

            printf(" %c",c);

          }

        printf("\n");

      }

  }

int main(void) {

  printf("the pattern is below\n");

  //Type the name of any above function here to print desired pattern 

// box('*');

 // right_angled('*');

  //right_angle_digit(1);

 // right_angle_star_rev('*');

  

  //for example the below function will print the pattern of star pyramid 

  star_pyramid('*');

  return 0;

}

🔗Link: https://replit.com/@AquaLeagen/Printingpattern-as-a-box?s=app

Comments

Popular Posts