Identify the errors in the following program.
#include <iostream>
using namespace std;
void main()
{
int i=5;
while(i)
{
switch(i)
{
default:
case 4:
case 5:
break;
case 1:
continue;
case 2:
case 3:
break;
}
i-;
}
}
Answer Posted / hr
case 1 :
continue;
The above code will cause the following situation:
Program will be continuing while value of i is 1 and value of i is updating. So infinite loop will be created.
Correction: At last line i- should be changed as i–;
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Explain the extern storage classes in c++.
When do we run a shell in the unix system? How will you tell which shell you are running?
Explain stl.
Write a java applet that computes and displays the squares of values between 25 and 1 inclusive and displays them in a TextArea box
how to making game in c++ ?
Is oop better than procedural?
What is the use of lambda in c++?
Can you use the function fprintf() to display the output on the screen?
What are oops functions?
What is difference between oop and pop?
What is the use of 'using' declaration in c++?
What are literals in C++?
Why oops is important?
What is operators in c++?
Write about the role of c++ in the tradeoff of safety vs. Usability?