0

difference between someone

#include <iostream> using namespace std; int main() { int x = 1; do { cout <<"this is loop" << endl; } while (x <= 15); return 0; } and #include <iostream> using namespace std; int main() { int x = 1; do { cout <<"this is loop" << endl; x++; } while (x <= 15); return 0; } the first one loop shows time limit exceed at the end of the line and the 2nd one showing correct (msg) at 15 times

29th Jul 2016, 7:44 AM
Manish Pant
Manish Pant - avatar
1 Answer
+ 1
you're missing x++; in the first one, it times out because it won't stop printing "this is a loop" because x never changes.
29th Jul 2016, 8:30 AM
Jaque
Jaque - avatar