Question: Is there any example for which the following two loops will not work same way?
If the body-statements contains continue, then the two programs will work in different ways
See the below examples: Program 1 will print “loop” 3 times but Program 2 will go in an infinite loop.
Example for program 1
Example for program 2
Please write comments if you want to add more solutions for the above question.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Difference between while(1) and while(0) in C language
- Difference between while and do-while loop in C, C++, Java
- Which will be faster while(1) or while(2)?
- typedef versus #define in C
- Scope Resolution Operator Versus this pointer in C++?
- Output of C programs | Set 56 (While loop)
- C/C++ while loop with Examples
- C/C++ do while loop with Examples
- Hello World Program : First program while learning Programming
- Types of C files after its compilation
- Food Ordering System in C
- Difference between sizeof(int *) and sizeof(int) in C/C++
- Examination Management System in C
- Difference between Static and Dynamic Memory Allocation in C