Sail E0 Webinar
Question


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
Options:
A .  2
B .  7
C .  9
D .  14
Answer: Option B

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 ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers