For Advertisements on this blog Contact Us at developgram@gmail.com or +91-9923438816

Simple Programming Tutorials For Beginners

Tuesday, January 10, 2017

Star Rhombus

/*
Summary: Print rhombus pattern of stars.
*/

#include<stdio.h>

int main()
{
    int row, col, n;
    
    printf("Enter the number of rows: ");
    scanf("%d", &n);
    
    for(row=1; row<=n; row++)
    {
        for(col=n; col>row; col--)
            printf(" ");
  printf("*");
      
        for(col=1; col<(row-1)*2; col++)
            printf(" ");
            
        if(row==1)
   printf("\n");
        else
   printf("*\n");
    }
    
    for(row=n-1; row>=1; row--)
    {
        for(col=n; col>row; col--)
            printf(" ");
  printf("*");
      
        for(col=1; col<(row-1)*2; col++)
            printf(" ");
            
        if(row==1)
   printf("\n");
  else 
   printf("*\n");
    }    
    
    return 0;
}

No comments:

Post a Comment

SEARCH THIS BLOG