Question
1.
#include
2.
using namespace std;
3.
int main ()
4.
{
5.
int a, b, c;
6.
a = 2;
7.
b = 7;
8.
c = (a > b) ? a : b;
9.
cout
What is the output of this program?
1.
#include
2.
using namespace std;
3.
int main ()
4.
{
5.
int a, b, c;
6.
a = 2;
7.
b = 7;
8.
c = (a > b) ? a : b;
9.
cout
Answer: Option B
Was this answer helpful ?
We are using the ternary operator to evaluate this expression. It will return first option, if first
condition is true otherwise it will return second
Output:
$ g++ ess1.cpp
$ a.out
7
Was this answer helpful ?
Submit Solution