Program in C To Print Hollow Rhombus, Parallelogram Star Pattern

Errorlogger
0
/* 1. Program to print the following output


    *****                                                                                                                                                                       
   *   *                                                                                                                                                                        
  *   *                                                                                                                                                                         
 *   *                                                                                                                                                                          
*****        
*/

#include <stdio.h>
int main()
{
    int i, j;
    for(i=1; i<=5; i++)
    {
        //Print trailing spaces
        for(j=1; j<=5-i; j++)
        {
            printf(" ");
        }
        //Print stars and center spaces
        for(j=1; j<=5; j++)
        {
            if(i==1 || i==5 || j==1 || j==5)
                printf("*");
            else
                printf(" ");
        }
        printf("\n");
    }
    return 0;
}


/* 2. Program to print the following output


    ********************                                                                                                                                                        
   *                  *                                                                                                                                                         
  *                  *                                                                                                                                                          
 *                  *                                                                                                                                                           
********************       
*/

#include <stdio.h>
int main()
{
    int i, j;
    for(i=1; i<=5; i++)
    {
        //Print trailing spaces
        for(j=1; j<=5-i; j++)
        {
            printf(" ");
        }
        //Print stars and center spaces
        for(j=1; j<=20; j++)
        {
            if(i==1 || i==5 || j==1 || j==20)
                printf("*");
            else
                printf(" ");
        }
        printf("\n");
    }
    return 0;
}

Post a Comment

0Comments

Post a Comment (0)

#buttons=(Accept !) #days=(30)

Our website uses cookies to enhance your experience. Check Now
Accept !