+ 4
10th Jan 2018, 3:04 PM
DEEPENDU PANDIT
DEEPENDU PANDIT - avatar
7 Respostas
+ 3
You don't get any output here, as your loop is an infinite one. The 'x' remains to be 5 and never becomes 6. So you need to assign it thr new value if you want the loop to end. Use the preincrement operation: #include <iostream> using namespace std; int main() {int x=5; while(x<9) cout<<++x; return 0; }
10th Jan 2018, 3:09 PM
ProCpp
+ 3
thanks..for helping 😍😍
10th Jan 2018, 3:14 PM
DEEPENDU PANDIT
DEEPENDU PANDIT - avatar
+ 2
@procpp i have mentioned my written code
10th Jan 2018, 3:07 PM
DEEPENDU PANDIT
DEEPENDU PANDIT - avatar
+ 2
It's because you are not increasing the value of x in the bucle, you join in a infinite loop. Write: cout << x++; and it will work. Another way is to do (inside the while bucle): cout << x; x += 1; // (or x++;)
10th Jan 2018, 3:09 PM
Sebastián Zapata
Sebastián Zapata - avatar
+ 2
@Misa Amane You may, but without the x++, ++x or x+=1, the loop executes forever.
10th Jan 2018, 3:13 PM
ProCpp
+ 1
Umm, where exactly? Can you share the code? Maybe you missed the 'int x' part?
10th Jan 2018, 3:06 PM
ProCpp
0
If x is not a function,cout<<x+1 will output only "x+1"
13th Feb 2018, 11:26 AM
Nightwolf
Nightwolf - avatar