Solid Box of Asterisks in C

Posted by Samath
  1478
December 21, 2014

 

Your task is to write a C program that accepts two positive integer values from the keyboard, say L and H. 
Both L and H will be less than 21. Your program then prints out a solid of box of asterisks, with L horizontal stars and H vertical stars. The box is filled with asterisks. For example,

If you were to type in 5 and 3, you output would be:

*****
***** 
*****

Solution:

#include <stdio.h>
int main(int argc, char *argv[])
{
	int num;
	int num2;
	
	printf("Enter a interger: ");
	scanf("%d",&num);
	
	printf("Enter a interger: ");
	scanf("%d",&num2);
		
	for(int i=0;i<num2;i++)
	{
		for(int i=0;i<num;i++)
		{
			printf("*");
		}
			printf("\n");
	}

	
	return 0;
}