home *** CD-ROM | disk | FTP | other *** search
/ Jason Aller Floppy Collection / 98.img / LCNOW2.ZIP / EXAMPLES / REPEAT.C < prev    next >
C/C++ Source or Header  |  1988-06-25  |  406b  |  26 lines

  1. /*
  2.  * R E P E A T
  3.  *
  4.  * Ask the user for a character and a count.  Display the
  5.  * character the number of times specified by count.
  6.  */
  7.  
  8. main()
  9. {
  10.     char ch;
  11.     int count;
  12.  
  13.     printf("Type the character to repeat: ");
  14.     scanf("%1s", &ch);
  15.     printf("Type the repetition count: ");
  16.     scanf("%d", &count);
  17.  
  18.     while (count > 0) {
  19.         printf("%c", ch);
  20.         --count;
  21.     }
  22.     printf("\n");
  23.  
  24.     return (0);
  25. }
  26.