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 is the use of default constructor?
What does it mean when someone says I oop?
What is the difference between containment and delegation?
Why do we need pointers?
What is c++ good for?
What is doubly linked list in c++?
What is a down cast?
What does count ++ do in c++?
What is a class in oop?
what you know about c++?
If dog is a friend of boy, is boy a friend of dog?
What is the basic concept of c++?
What is class in c++ with example?
What is the extraction operator and what does it do?
How to defines the function in c++?