When to use while(0) and while(1)?

Answer

The while keyword is used to apply condition for execution of the loop. It is control flow statement, in which a condition is specified, which may be either true or false at a time, and allows the execution accordingly.

while(1) is as similar as writing any integer other than 0. It allows the execution of given loop infinite number of times, without any break. However, this increases the usage of CPU.

while(0) tells that the specified condition will always remain false, resulting in no execution of code.

All c++ Questions

Ask your interview questions on c

Write Your comment or Questions if you want the answers on c from c Experts
Name* :
Email Id* :
Mob no* :
Question
Or
Comment* :
 





Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---