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
What are static member functions?
What does asterisk mean in c++?
What is null and void pointer?
What are vtable and vptr?
What are namespaces in c++?
Will c++ be replaced?
What is a rooted hierarchy?
Explain what are accessor methods?
What is a constant? Explain with an example.
What is the best c++ book?
What is the best c++ compiler for windows 10?
What are the advantage of using register variables?
What new()is different from malloc()?
Can destructor be overloaded?
Show the declaration for a pointer to function returning long and taking an integer parameter.