Sail E0 Webinar
Question


What is the output of this program?


1.
#include
2.
using namespace std;
3.
int main()
4.
{
5.
char* buff;
6.
try {
7.
buff = new char[1024];
8.
if (buff == 0)
9.
throw "Memory allocation failure!";
10.
else
11.
cout
Options:
A .  4 Bytes allocated successfully
B .  8 Bytes allocated successfully
C .  Memory allocation failure
D .  depends on the size of data type
Answer: Option D

As we are allocating the memory to the variables and if there is not suffcient size means, it 

will throw an exception.
Output:
$ g++ excep3.cpp
$ a.out
4 Bytes allocated successfully



Was this answer helpful ?
Next Question

Submit Solution

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

Latest Videos

Latest Test Papers