Q. How many times the word “Apple” will be displayed on screen ? Before giving answers check the continue and break statements.

<br />#include
using namespace std;
int main()
{
int x;
for(x=-1; x<=10; x++)
{
if(x < 5)
continue;
else
break;
cout<<"Apple";
}
return 0;
}

Answer:- Whenever x is less than 5, the loop will continue then after it will break and nothing will be printed on the screen because it is the property of break statement that it always ends execution of the nearest enclosing do, for or while statement.

Leave a comment