Willie Trombone
Honorary Master
- Joined
- Jul 18, 2008
- Messages
- 60,038
What I'd expect it to do is either count to the number of specified iterations or 10, whichever is smaller. It seems to ignore the second part of the or condition in the while loop and stop only when the number of specified iterations is up (regardless of how many). What is wrong with this simple snipped of code?
Lol... Never mind, I can see it staring at me now lol...
it should be && - not ||
eish man... it's late
Code:
#include <stdio.h>
#include <stdlib.h>
int main() {
int iteration, counter;
setbuf(stdout, 0);
counter=1;
printf("\nPlease enter how many iterations you would like: ");
scanf("%d",&iteration);
do {
printf("\nIteration number %d of %d", counter,iteration);
counter ++;
} while (counter <= iteration || counter <= 10);
return 0;
}
Lol... Never mind, I can see it staring at me now lol...
it should be && - not ||
eish man... it's late
Last edited: