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 difference between a baller and a reference in C++?
Name the debugging methods that are used to solve problems?
What is c++ in english?
What are arrays c++?
Differentiate between an array and a list?
Explain the uses oof nested class?
Explain the difference between c & c++?
What is the history of c++?
What are the c++ access specifiers?
What does enum stand for?
Explain the concept of copy constructor?
Can create new c++ operators?
Why iomanip is used in c++?
What is super in oop?
What are the different types of polymorphism in c++?