Guest User

Untitled

a guest
Feb 21st, 2018
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. /* asks the user to enter a number and prints out the corresponding
  5. * number of asterisks */
  6. int main(void)
  7. {
  8. int i = 0, value = 1, result = 1;
  9.  
  10. /* we want to keep looping until the user enters either 0 or a
  11. * negative number */
  12. while(value > 0)
  13. {
  14. printf ("Enter a number: ");
  15.  
  16. /* grab the input from the user */
  17. result = scanf("%d", &value);
  18. fflush(stdin);
  19.  
  20. if(!result)
  21. {
  22. /* user must enter a numeric value */
  23. printf("Value must be numeric");
  24. continue;
  25. }
  26.  
  27. for (i = 0; i < value; i++)
  28. {
  29. printf("*");
  30. }
  31.  
  32. printf("\n");
  33. }
  34. }
Add Comment
Please, Sign In to add comment