/* * This one almost works for Homeowrk 5, * but goes into an infinite loop if I type -2 then type quit */ #include #include int main() { int n, m ; int stop, matched ; stop = 0 ; while (!stop) { printf("Please enter a positive number (type 'quit' to end): ") ; matched = scanf("%d", &n) ; while (n <= 0) { printf("%d is not a positive number!\n", n) ; printf("Please enter a positive number (type 'quit' to end): ") ; matched = scanf("%d", &n) ; } if (matched <= 0) { stop = 1 ; } else { m = 0 ; while (m < n) { printf ("*") ; m = m + 1 ; } printf ("\n") ; } } return 0 ; }