C Programming language

adplus-dvertising
C Program example: Enter a number and print Star Rectangle
Previous Home Next

In this example we are going to explain how we can make a star rectangle using C language. In this example we are inserting number of rows and columns .Then we are printing stars to make rectangle.

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

#include<stdio.h>
#include<conio.h>
void main()
{
	int i,j,row,col;
    clrscr();
    printf("Enter the row and column\t");
    scanf("%d%d",&row,&col);
    for(i=1;i<=row;i++)
    {
		for(j=1;j<=col;j++)
			printf("*");
		printf("\n");
    }
    getch();
}
Output: Enter the row and column 4 4
     * * * *
     * * * *
     * * * *
     * * * *
Previous Home Next