Question
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
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
Answer: Option D
Was this answer helpful ?
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 ?
Submit Solution