Search C Program

Star Pattern - 3

    *
   **
  ***
 ****
*****
 
#include <stdio.h>

int main()
{
    int i, j, k;
    for(i=5;i>=1;i--)
    {
        for(j=1;j<i;j++)
        {
            printf(" ");
        }
        for(k=5;k>=i;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

11 comments:

  1. Than a lot ........this helped me alot........

    ReplyDelete
  2. star pattern 3 coding is rong

    ReplyDelete
  3. #include
    main()
    {
    int n;
    printf("enter no of rows:");
    scanf("%d",&n);
    int temp=n;
    for(int r=1;r<=n;r++)
    {
    for(int c=1;c<temp;c++)
    printf(" ");
    temp--;
    for(c=1;c<=r;c++)
    printf("*");
    }
    }

    ReplyDelete
  4. pattern 3:

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

    ReplyDelete
  5. this is not working properly

    ReplyDelete
  6. Pattern 3:just 2 for loops

    int main() {

    int n,i,j;

    scanf("%d",&n);

    for(i=0;i=n-1)
    {
    printf("#");
    }
    else
    {
    printf(" ");
    }

    }
    printf("\n");
    }

    return 0;
    }

    ReplyDelete
  7. #include
    #include
    void main()
    {
    int i,j ,k ,n;
    printf("Enter no. of rows");
    scanf("%d",&n);

    for(i=n; i>=1; i--)
    {
    for(j=1; j<=1;j++)
    {
    printf(" ");
    }
    for(k=1; k<=n; k++)
    {
    printf("*");
    }
    printf("\n");
    }
    return 0;
    }

    ReplyDelete
  8. Can someone please explain the logic?

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

    ReplyDelete
  10. int main()
    {
    int i,j,n=9;
    for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
    if(j>=(n-i+1))
    cout<<"*";
    else
    cout<<" ";
    }
    cout<<endl;
    }
    }

    ReplyDelete