Advertisement
Sierra_ONE

Repeat the Character

Oct 8th, 2023
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.57 KB | Source Code | 0 0
  1. /*
  2. 2. Repeat the character
  3. Make program that will get one character (CH) and number (N) from input.
  4.  
  5. Print the character N times to output.
  6.  
  7.  
  8.  
  9. Character can be any character from ASCII table with number higher than 32 and smaller than 127
  10.  
  11. 0 <= N <= 100
  12. */
  13.  
  14. #include <stdio.h>
  15.  
  16. int main (void){
  17.  
  18.     char character;
  19.     int num, i;
  20.  
  21.     printf("Enter the character: ");
  22.     scanf("%c", &character);
  23.     printf("Enter the number: ");
  24.     scanf("%d", &num);
  25.  
  26.     for (i = 0 ; i < num ; i++ ){
  27.         printf("%c", character);
  28.     }
  29.  
  30.  
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement