Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- /* asks the user to enter a number and prints out the corresponding
- * number of asterisks */
- int main(void)
- {
- int i = 0, value = 1, result = 1;
- /* we want to keep looping until the user enters either 0 or a
- * negative number */
- while(value > 0)
- {
- printf ("Enter a number: ");
- /* grab the input from the user */
- result = scanf("%d", &value);
- fflush(stdin);
- if(!result)
- {
- /* user must enter a numeric value */
- printf("Value must be numeric");
- continue;
- }
- for (i = 0; i < value; i++)
- {
- printf("*");
- }
- printf("\n");
- }
- }
Add Comment
Please, Sign In to add comment