Pattern 17 : Arrow star pattern program in C language using Patterns.

Write a C program to print the following Arrow star pattern using for loops:

C Program to print the Arrow star pattern here is an example output, if the user input is 5.

Note: This program is one of the program in Series of Star Pattern programs in C

 Program to print Arrow star pattern on Console:

  1. #include<stdio.h>
  2. int main()
  3. {
  4.    int i,j,k,num;
  5.    printf(“Enter any value : “);
  6.    scanf(“%d”,&num);
  7.    for(i=-num;i<=num;i++)
  8.    {
  9.       k=i;
  10.       if(k<0)
  11.       {
  12.          k = k * 1;
  13.       }
  14.       for (= 0; j <= num; ++j)
  15.       {
  16.          if (j<k)
  17.          {
  18.             printf(”  “); // two spaces
  19.          }
  20.          else
  21.          {
  22.             printf(“*”);  // one star only
  23.          }
  24.       }
  25.       printf(“\n);
  26.    }
  27.    return 0;
  28. }

Output :

Arrow-star-pattern-in-c-language

Related Programs :

More C programs:

C Tutorials with simple Examples:

Venkatesh

Hi Guys, I am Venkatesh. I am a programmer and an Open Source enthusiast. I write about programming and technology on this blog.

You may also like...

2 Responses

  1. Magra says:

    Here is the python version of it, (Easy to understand)

    Code:

    num = int(input(“provide input “))

    for i in range(num*2):
    print(” ” * ((num-1-i)*2),end=”)
    print(” ” * ((num-1-i)*2*(-1)),end=”)
    print(“*” * (i+1))

    • Abdullah says:

      This pattern is left direction ,how reverse it to right direction

Leave a Reply