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

If class D is derived from a base class B

0 Answers  


What is RTTI and why do you need it?

0 Answers   Amazon,


Write a program to generate the Fibonocci Series in C++.

0 Answers   Accenture,


What is constant keyword in C++? Illustrate its various uses.

0 Answers   Akamai Technologies, Infogain,


How do you write a function that can reverse a linked-list in C++?

0 Answers   IBS,






Implement a 2D bit-matrix representing monochrome pixels which will have only OFF/ON values and will take on an average only one bit of memory for each stored bit. How to perform various operations on it?

0 Answers   Adobe,


What Is Polymorphism in C++ ?

1 Answers   IBS, Impetus, ITC Indian Tobacco Company, Motorola,


What is an abstract class in C++

0 Answers   SwanSoft Technologies,


What does it mean to take the address of a reference?

0 Answers   Amazon,


What is the difference between Stack and Queue in C++?

0 Answers   Global Logic, iNautix,


CDPATH shell variable is in(c-shell)

0 Answers   Siemens,


Briefly explain various access specifiers in C++.

0 Answers   Amdocs,


Categories