Free CPA-21-02 Exam Braindumps (page: 36)

Page 36 of 65

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

#include <iostream>

using namespace std;

int op(int x, int y);

int main()
{
int i=2, j=2, k;
float f=0.3;
k = op(i, j);
cout<< k << "," << op(1, f);
return 0;
}

int op(int x, int y)
{
return x+y;
}

  1. It prints: 4,1
  2. It prints: 4,0.7
  3. It prints: 4,0
  4. It prints: 0,4

Answer(s): A



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

#include <iostream>
using namespace std;

int main(){
int i = 1;
if (i++==1) {

cout << i;
} else {
cout << i-1;
}
return 0;
}

  1. It prints: 0
  2. It prints: 1
  3. It prints: -1
  4. It prints: 2

Answer(s): D



Which code, inserted at line 12, generates the output "5b"?

#include <iostream>
using namespace std;
namespace myNamespace1
{
int var = 5;
}
namespace myNamespace2
{
char var = 'b';
}
int main () {
//insert code here return 0;
}

  1. cout << myNamespace1::var << var;
  2. cout << var << var;
  3. cout << myNamespace1::var << myNamespace2::var;
  4. None of these

Answer(s): C



What will be the output of the program?

#include <iostream>

using namespace std;

int main()
{
const int y = 5;
const x = ?10;
cout<<x<<" "<<y;
return 0;
}

  1. ?10 5
  2. 5 ?10
  3. Compilation error
  4. None of these

Answer(s): C



Page 36 of 65



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

Subash commented on October 21, 2024
I am planning to take this exam. Are these 257 questions enough to clear it? Also, does each section have a passing percentage, or is it based on the overall ?
INDIA
upvote