Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

What will be the output of the following C++ code? #include <iostream>
using namespace std;
int main ()
{
int n;
for (n = 5; n > 0; n–)
{
cout << n;
if (n == 3)
break;
}
return 0;
}

What will be the output of the following C++ code? #include <iostream>
using namespace std;
int main ()
{
int n;
for (n = 5; n > 0; n–)
{
cout << n;
if (n == 3)
break;
}
return 0;
}
a) 543
b) 54
c) 5432
d) 53

Answer: a
Explanation: In this program, We are printing the numbers in reverse order but by using break statement we stopped printing on 3.
Output:
543

Join The Discussion