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 is the difference between realloc() and free() in C++?

0 Answers   IBS, TCS,


What is meant by exit controlled loop?

0 Answers   Adobe,


Difference between function overloading and function overriding.

0 Answers   Alter,


What is a memory leak in C++?

0 Answers   Agilent,


Explain what happens when an exception is thrown in C++.

0 Answers   Amazon,






what is the difference between a pointer and a reference?

0 Answers   Amazon, Blue Star, C DAC,


Explain the operator overloading feature in C++ ?

0 Answers  


Write a C++ program to print strings in reverse order.

0 Answers   Amdocs,


Write a C++ Program to Find whether given Number is Odd or Even.

1 Answers  


Declare a pointer to a function that takes a char pointer as argument and returns a void pointer.

0 Answers   Alter,


Can we use THIS Pointer in static function – Reason in C++?

0 Answers  


Explain encapsulation in C++.

0 Answers   Verifone,


Categories