Search C Program | nimishsoft@gmail.com

Star Pattern - 5

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

#include <stdio.h>

int main()
{
    int i, j, k;
    for(i=1;i<=5;i++)
    {
        for(j=i;j<5;j++)
        {
            printf(" ");
        }
        for(k=1;k<(i*2);k++)
        {
                printf("*");
        }
        printf("\n");
    }

    return 0;
}
Related Links:
- More Number Pattern Programs
- Star Pattern Programs in C
- Alphabet Pattern Programs in C
- Series Programs in C

40 comments:

  1. good programming, easy to understand!!1

    ReplyDelete
  2. all wrong codes!!!!!!!!!!!!!!!

    ReplyDelete
    Replies
    1. This code is tested on codepad. check this link http://codepad.org/YQSAu3Lq

      Delete
    2. YES, ITS CORRECT.

      Delete
  3. Replies
    1. as i said before this code is verified at codepad.ora, check following link
      http://codepad.org/YQSAu3Lq

      Delete
    2. check the output on http://codepad.org/YQSAu3Lq

      Delete
    3. no its working its coming but not in a triangle shape but in a half triangle

      Delete
  4. #include

    int main()
    {
    int i, j, k;
    for(i=1;i<=5;i++)
    {
    for(j=n-i;j>=1;j--)
    {
    printf(" ");
    }
    for(k=1;k<(2*n-1);k++)
    {
    printf("*");
    }
    printf("\n");
    }

    return 0;
    }

    ReplyDelete
    Replies
    1. @nimish-I can understand that :)
      @Avinash- What is 'n' in --> "for(k=1;k<(2*n-1);k++)" ??

      Delete
    2. #include

      int main()
      {
      int i, j;
      for(i=1;i<=5;i++)
      {
      for(j=1;j<=9;j++)
      {
      if(J>=6-i && j<=4+i)
      {
      print("*");
      }
      else
      {
      printf(" ");
      }

      }
      printf("\n");

      }

      Delete
  5. the code is wrong buddy

    ReplyDelete
    Replies
    1. check running version of this code at http://codepad.org/YQSAu3Lq

      Delete
  6. Check out this code for input of any no of rows:

    #include
    void main()
    {
    int i,j,k,n;
    printf("Enter the no of rows \n");
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
    for(j=n;j>i;j--)
    {
    printf(" ");
    }
    for(k=1;k<=i*2-1;k++)
    {
    printf("*");
    }
    printf("\n");
    }
    }

    ReplyDelete
    Replies
    1. you have written the same code,moreover you have rather added few characters to make it cumbersome..

      Delete
  7. this code is right I executed it and successfully got output. please explain it line by line doing specially for(k=1;k<=i*2-1;k++) this loop

    ReplyDelete
  8. this blog is perfect and the 1st code is very easy to understand.

    ReplyDelete
  9. Try this one.

    #include
    int main()
    {
    int i,j,n;
    printf("Enter a value=\n");
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
    for(j=1;j<=n-i;j++)
    printf(" ");
    for(j=1;j<=2*i-1;j++)
    printf("*");
    printf("\n");
    }
    //printf("\n");
    return 0;
    }

    ReplyDelete
  10. Replies
    1. Abe chutiya hai kya ..ek line ka code ata nahi aur chala ata hai ..wrong batane ..stop buzzing unnecessarily

      Delete
  11. Dear anonymous, we got that it's wrong code than why don't you provide the right code instead of captioning wrong code at every comment. Plz provide soln not suggestions or statements. 😊

    ReplyDelete
  12. The code is working fine :) thanks

    ReplyDelete
  13. how you are managing spaces in the pattern?

    ReplyDelete
  14. in the third loop there should be 2*i-1.That,s it and every thing is fucking fine

    ReplyDelete
    Replies
    1. What you said was right dude. ��

      Delete
  15. Main()
    {int I, j;
    for(I=0;I<=4;I++)
    for(j=4-I; j<=4+I; j++)
    Printf("*");

    }

    ReplyDelete
  16. can you describe the logic of the program

    ReplyDelete
  17. Great blog ! Keep it up.

    ReplyDelete
  18. #include
    void main()
    {
    int i,j,k,l;
    for(i=1;i<=5;i++)
    {
    for(k=5;k>i;k--)
    {
    printf(" ");
    }


    for(j=1;j<(i*2);j++)

    printf("*");

    puts("");
    }
    }

    ReplyDelete
  19. #include
    void main()
    {
    int i,j;
    for(i=1;i<=5;i++)
    {
    for(j=1;j<=9;j++)
    {
    if(j>=6-i && j<=4+i)
    {
    printf("*");
    }else{
    printf(" ");
    }

    }
    printf("\n");
    }
    }

    ReplyDelete
  20. Advanced Level Star Pattern Programs In Java
    Read Now

    ReplyDelete
  21. Why can't the output is a bit wierd when n=6 or above try first

    ReplyDelete
  22. Ignore why can't accidently written

    ReplyDelete