Sail E0 Webinar
Question


What is the output of this program?


1.
#include
2.
using namespace std;
3.
int main()
4.
{
5.
int a = 10, b = 20, c = 30;
6.
float d;
7.
try
8.
{
9.
if ((a - b) != 0)
10.
{
11.
d = c / (a - b);
12.
cout
Options:
A .  10
B .  -3
C .  15
D .  none of the mentioned
Answer: Option B

We are manipulating the values, if there is any infinite value means, it will raise an exception.
Output:
$ g++ gex2.cpp
$ a.out
-3



Was this answer helpful ?
Next Question

Submit Solution

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

Latest Videos

Latest Test Papers