Hi guys. I wrote a small program where the user inputs a number and the program prints the number in asterisks. I used a for loop for this. However when I put the for loop inside a while loop to keep looping the program, it goes into an infinite loop. I just can't seem to figure out what the problem is.
Without the while loop the for loop works perfectly, printing out the asterisk(s). It's when I add the while loop that things get ugly.
Code:#include <stdio.h> int main(void) { int number, counter; printf("Enter number: "); scanf("%d", &number); while (number > 0){ for (counter = 0; counter < number; counter++){ printf("*"); } } }



LinkBack URL
About LinkBacks



