What happens when you attempt to compile and run the following code? #include
using namespace std;
int main()
{
int a=5;
cout << ((a < 5) ? 9.9 : 9);
}
A. It prints: 9
B. It prints: 9.9
C. Compilation error
D. None of these
What happens when you attempt to compile and run the following code?
#include
using namespace std;
int main()
{
int *t;
t = new int[2];
for (int i=0; i<2; i++) {
t[i] = i;
}
cout << t[1];
}
A. It prints: 0
B. It prints: 1
C. It prints: 10
D. It prints: ?1
What is the output of the program?
#include
#include
using namespace std;
class First
{
string name;
public:
First() {
name = "Alan";
}
void setName(string n) {this?>name = n;}
void setName() {this?>name = "John";}
void Print(){
cout << name;
}
};
int main()
{
First ob1,*ob2;
ob2 = new First();
First *t;
t = andob1;
t?>setName();
t?>Print();
t = ob2;
t?>setName("Steve");
ob2?>Print();
}
A. It prints: JohnSteve
B. It prints: AlanAlan
C. It prints: AlanSteve
D. It prints: JohnAlan
What happens when you attempt to compile and run the following code?
#include
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;
}
A. It prints: 4,1
B. It prints: 4,0.7
C. It prints: 4,0
D. It prints: 0,4
The following declaration: int i = 0b10;
A. is invalid
B. sets variable i with an integer value equal to 10
C. sets variable i with an integer value equal to 2 (10 binary)
D. sets variable i with an integer value equal to 8 (10 octal)
What happens when you attempt to compile and run the following code?
#include
using namespace std;
int main()
{
int i=5;
switch(i)
{
case 1:
cout<<"Hello";
break;
case 2:
cout<<"world";
break;
case 3:
break;
default:
cout<<"End";
}
return 0;
}
A. It prints: Hello
B. It prints: world
C. It prints: End
D. It prints: Helloworld
If there is one, point out an error in the program
#include
using namespace std;
int main()
{
int i=1;
for(;;)
{
cout<
if(i>5)
break;
}
return 0;
}
A. Error in "if" statement
B. Error in "for" loop
C. No error
D. Error in break statement
What will happen when you attempt to compile and run the following code?
#include
using namespace std;
int main (int argc, const char * argv[])
{
enum state { ok, error, warning};
enum state s1, s2, s3;
s1 = ok;
s2 = warning;
s3 = error;
s4 = ok;
cout << s1<< s2<< s3;
return 0;
}
A. It will print:"123"
B. compilation error
C. It will print:"021"
D. It will print:"132"
Which code line inserted instead of the comment below will fix the program so that it produces the expected output and does not cause any memory leak?
A. delete [] p;
B. delete p[];
C. delete p;
D. delete *p;
What happens when you attempt to compile and run the following code?
#include
#include
using namespace std;
int main()
{
string s1[]= {"How" , "to" };
s1[0].swap(s1[1]);
for (int i=0; i<2; i++) {
cout << s1[i];
}
return( 0 );
}
A. It prints: Hoto
B. It prints: toHow
C. It prints: Ht
D. It prints: to
Nowadays, the certification exams become more and more important and required by more and more enterprises when applying for a job. But how to prepare for the exam effectively? How to prepare for the exam in a short time with less efforts? How to get a ideal result and how to find the most reliable resources? Here on Vcedump.com, you will find all the answers. Vcedump.com provide not only C++ Institute exam questions, answers and explanations but also complete assistance on your exam preparation and certification application. If you are confused on your CPA-21-02 exam preparations and C++ Institute certification application, do not hesitate to visit our Vcedump.com to find your solutions here.