One Horizontal Line of Asterisks in C

Posted by Samath
  1452
December 21, 2014

 

Create a C program that uses the scanf function to read in a integer value and then prints a horizontal 
line containing that many asterisks' (*). Use a for-loop in your program. For example,

Enter a interger: 8       

********

Code:

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