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


Please Help Members By Posting Answers For Below Questions

Why is c++ a mid-level programming language?

589


What new()is different from malloc()?

565


What is function overriding in c++?

599


How would you obtain segment and offset addresses from a far address of a memory location?

612


Can we overload operator in c++?

544






What is iostream in c++ used for?

544


What are the advantages of c++?

589


Write a note about the virtual member function?

597


What is private inheritance?

592


How Do you Code Composition and Aggregation in C++ ?

24186


Is it possible to use a new for the reallocation of pointers ?

591


What is command line arguments in C++? What are its uses? Where we have to use this?

571


Can you help me with this one? Make a program that when a user inputed a Product Name, it will display its price, and when the user inputed the quantity of the inputed product, it will show its total price. The output must be like this: Product Name: Price: Quantity: Total Price: ..this is the list of products to be inputed: Cellphone - 1500 Washing Machine - 5200 Television - 6000 Refrigirator - 8000 Oven - 2000 Computer - 11000 thanks..:D

3047


Function can be overloaded based on the parameter which is a value or a reference. Explain if the statement is true.

641


What is meaning of in c++?

665