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-;
}
}



Identify the errors in the following program. #include <iostream> using namespace std; vo..

Answer / 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

More C++ Interview Questions

What are pass by value and pass by reference?what is the disadvantage of pass by value?

0 Answers   Alter,


Explain the difference between method overriding and method overloading in C++?

0 Answers   Accenture,


How can you force the compiler to not generate them?

0 Answers   Amazon,


Without using third variable write a code to swap two numbers.

0 Answers   Accenture,


In C++ what do you mean by Inheritance?

0 Answers   Accenture,


Tell me about virtual function

1 Answers  


What is the difference between realloc() and free() in C++?

0 Answers   IBS, TCS,


How to convert integer to string in C++

0 Answers  


What is data abstraction? How is it implemented in C++?

0 Answers   Amdocs,


explain the term 'resource acquisition is initialization'?

0 Answers   Amazon,


What is Coupling?

0 Answers   Cap Gemini,


What is placement new?

1 Answers   Amazon,


Categories