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
Why is c++ a mid-level programming language?
What new()is different from malloc()?
What is function overriding in c++?
How would you obtain segment and offset addresses from a far address of a memory location?
Can we overload operator in c++?
What is iostream in c++ used for?
What are the advantages of c++?
Write a note about the virtual member function?
What is private inheritance?
How Do you Code Composition and Aggregation in C++ ?
Is it possible to use a new for the reallocation of pointers ?
What is command line arguments in C++? What are its uses? Where we have to use this?
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
Function can be overloaded based on the parameter which is a value or a reference. Explain if the statement is true.
What is meaning of in c++?