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

Simple Programming Tutorials For Beginners

Tuesday, January 10, 2017

Star Rectangle

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

#include<stdio.h>

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

No comments:

Post a Comment

SEARCH THIS BLOG