1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Program For Printing * in different Fashion

Discussion in 'C' started by SHEVATEGANESH, Aug 24, 2011.

  1. SHEVATEGANESH

    SHEVATEGANESH New Member

    Joined:
    Aug 24, 2011
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    *
    **
    ***
    ****
    *****

    #include<stdio.h>
    #include<conio.h>

    void main()
    {
    int n,i,j,k,count;
    clrscr();
    printf("Enter Number");
    scanf("%d",&n);
    count=n;
    for(i=1;i<=n;i++)
    {
    for(k=2;k<=count;k++)
    {
    printf(" ");
    }
    count--;
    for(j=1;j<=i;j++)
    {
    printf("* ");
    }
    printf("\n");
    }
    getch();
    }



    and
    *****
    ****
    ***
    **
    *

    #include<stdio.h>
    #include<conio.h>

    void main()
    {
    int n,i,j,k,count;
    clrscr();
    printf("Enter Number: ");
    scanf("%d",&n);
    count=1;
    for(i=n;i>=1;i--)
    {
    for(k=count;k>=2;k--)
    {
    printf(" ");
    }
    count++;
    for(j=i;j>=1;j--)
    {
    printf("* ");
    }
    printf("\n");
    }
    /*count=n-1;
    for(i=2;i<=n;i++)
    {
    for(k=count;k>1;k--)
    {
    printf(" ");
    }
    count--;
    for(j=1;j<=i;j++)
    {
    printf("* ");
    }
    printf("\n");
    } */
    getch();
    }
     

Share This Page