Free CPA Exam Braindumps (page: 24)

Page 24 of 56

What happens when you attempt to compile and run the following code?

#include <iostream>

using namespace std;

int main()
{
int x=0;
int *ptr;


ptr = &x;
cout<<x<<" "<<*ptr;


return 0;
}

  1. It prints: 0 0
  2. It prints address of ptr
  3. It prints: 1
  4. It prints: 2

Answer(s): A



Given:

#include <iostream>
#include <exception>
using namespace std;


int main () {
try
{
int * myarray= new int[1000];
}
catch (bad_alloc&)
{
cout << "Error allocating memory";
}
catch (exception& e)
{
cout << "Standard exception";
}
catch (...)
{
cout << "Unknown exception";
}
return 0;
}

What will happen if we use the operator “new” and the memory cannot be allocated?

  1. It prints: Error allocating memory
  2. It prints: Standard exception
  3. It prints: Unknown exception
  4. Compilation error

Answer(s): A



What happens when you attempt to compile and run the following code?

#include <iostream>

using namespace std;


struct {
int x;
char c;
union {
float f;
int i;
};
} s;


int main (int argc, const char * argv[])
{
s.x=10;
s.i=0;
cout << s.i << " " << s.x;
}

  1. It prints: 0 10
  2. It prints: 11
  3. Compilation error
  4. None of these

Answer(s): A



What is the output of the program?

#include <iostream>
#include <string>

using namespace std;

int main () {
string s1 = "Hello", s2 = "World";
s2 = s1 + s2;
cout << s2;
return 0;
}

  1. It prints: Hello
  2. It prints: HelloWorld
  3. It prints: WorldHello
  4. It prints: WorldHelloWorld

Answer(s): B



Page 24 of 56



Post your Comments and Discuss C++ Institute CPA exam with other Community members:

Inbarajan commented on January 02, 2025
Very useful
Anonymous
upvote

Heidi commented on January 02, 2025
Good practice set
CANADA
upvote

IT commented on January 02, 2025
is the exams changed? tropics ??
UNITED STATES
upvote

Nari commented on January 02, 2025
Thanks for sharing the questions for practice exam
INDONESIA
upvote

Adesosun Saidi commented on January 02, 2025
Planning to write the test soon
UNITED ARAB EMIRATES
upvote

Edward M commented on January 02, 2025
really helpful
UNITED STATES
upvote

Chandra commented on January 02, 2025
Need to have a look at the other Questions too.
UNITED STATES
upvote

Prasad commented on January 02, 2025
Useful Data
UNITED STATES
upvote

Renjith Raj commented on December 31, 2024
very good questions
Anonymous
upvote

Sapna M commented on December 31, 2024
Very descriptive and easy to understand due to links provided.
INDIA
upvote

hvt commented on December 31, 2024
really useful and max free questions upto 27 at least
Anonymous
upvote

Ahmed Beshara commented on December 31, 2024
Explanation is very helpful
SAUDI ARABIA
upvote

Den commented on December 31, 2024
Usefull data
UNITED STATES
upvote

Abhishek commented on December 30, 2024
It's a useful deck
Anonymous
upvote

Ramba commented on December 30, 2024
is this valid?
EUROPEAN UNION
upvote

Sith commented on December 30, 2024
Anyone taken the exam recently?
CANADA
upvote

sith commented on December 30, 2024
Are these question still valid ? can someone please confirm?
CANADA
upvote

Frank Smith commented on December 30, 2024
Excellent material for exam preparation
COSTA RICA
upvote

Anonymous commented on December 30, 2024
thank you for sharing
Anonymous
upvote

NB commented on December 30, 2024
good support
Anonymous
upvote

Karanpeet Sachdeva commented on December 30, 2024
Preparing for exam
INDIA
upvote

Harshini commented on December 30, 2024
Good Practice
Anonymous
upvote

Uzman commented on December 30, 2024
great collection
Anonymous
upvote

Md Habibur Rahman commented on December 30, 2024
Very helpful
BANGLADESH
upvote

Kollur commented on December 29, 2024
Best questions for preparation
JAPAN
upvote

Kollur commented on December 29, 2024
Usefull data
JAPAN
upvote

dinesh commented on December 29, 2024
Useful data
AUSTRALIA
upvote

Max commented on December 29, 2024
You’re the best
Anonymous
upvote

Deepika Deshmukh commented on December 29, 2024
very helpful content it helps a lot
Anonymous
upvote

Criss commented on December 29, 2024
Very nice and very good questions
Anonymous
upvote

Real truth commented on December 29, 2024
this is crap
Anonymous
upvote

Md commented on December 29, 2024
Totally worth it!
Anonymous
upvote

Datahighway commented on December 29, 2024
nice very good Stuff
UNITED STATES
upvote

Mon88 commented on December 29, 2024
is this dumps still valid to take the exam
UNITED STATES
upvote