One Horizontal Line of Asterisks in C
Posted by Samath
Last Updated: 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;
}

 

Related Content
Solid Box of Asterisks in C
Solid Box of Asterisks in C
Samath | Dec 21, 2014