0% found this document useful (0 votes)
49 views1 page

A 8 Q 1

The program contains a validate function that throws different data types based on the value of the integer passed to it. It contains multiple catch blocks to handle the different data types thrown. Calling validate with values of 0, 1, and -1 will cause it to throw 0, 1.0, and "negetive" respectively. The output will be the values caught and printed by each catch block in the order the exceptions are thrown.

Uploaded by

Aer Z
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views1 page

A 8 Q 1

The program contains a validate function that throws different data types based on the value of the integer passed to it. It contains multiple catch blocks to handle the different data types thrown. Calling validate with values of 0, 1, and -1 will cause it to throw 0, 1.0, and "negetive" respectively. The output will be the values caught and printed by each catch block in the order the exceptions are thrown.

Uploaded by

Aer Z
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

Consider the program given below.

#include<iostream>

void validate(int i){


try
if(i <0)
throw "negetive";
else if(i > 0)
throw i * 1.00;
else
throw 0;

catch(int ){ std::cout << "int "; } //LINE-1

catch(float ){ st

cout << "float


catch(const char* ){ std::cout << "

5} //LINE-2
har *"; } //LINE-3

3
int main({
yl
validate(0);
validate(1);
validate(-1);
3
catch(...) { std::cout << "ALL"; } //LINE-4
3

What will be the output?


a) int float char *
b) int float

©) int ALL

d) int ALL char *

You might also like