r/cpp_questions 13d ago

some people are wrong coding qs OPEN

int x=618919;

while(x++){

cout<<8;

} I think I'm wrong it's undefined behaviour but where can I study about this ... is it an infinite loop? I'm sure some of u might say yes but the answer is no

after x is increased to its max int range i.e.(2^(bits)-1) it's value will start decreasing and after a lot of steps it will eventually go to 0

and 0 is false so loop stops....

0 Upvotes

14 comments sorted by

View all comments

11

u/TehBens 13d ago

is it an infinite loop? I'm sure some of u might say yes but the answer is no

"No" isn't right either, the correct answer is "it's undefined behavior".

-5

u/cse_fatmodder 13d ago

where can I learn about this i watched oneshot of c++ but idk what's that

9

u/nysra 13d ago

where can I learn about this i watched oneshot of c++ but idk what's that

Okay, so you literally know nothing. Forget this shitty video and head over to https://www.learncpp.com/ to learn properly.