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:

  1. #include <stdio.h>
  2. int main(int argc, char *argv[])
  3. {
  4. int num;
  5. printf("Enter a interger: ");
  6. scanf("%d",&num);
  7. for(int i=0;i<num;i++)
  8. {
  9. printf("*");
  10. }
  11. printf("\n");
  12. return 0;
  13. }

 

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