Which code, inserted at line 14, generates the output "3.14 10"?
#include
using namespace std;
namespace myNamespace1
int x = 5;
int y = 10;
} namespace myNamespace2 { float x = 3.14; float y = 1.5; } int main () { //insert code here cout << x << " " << y; return 0; }
A. using myNamespace2::y; using myNamespace1::x;
B. using namespace myNamespace1;
C. using namespace myNamespace1; using namespace myNamespace2;
D. using myNamespace1::y; using myNamespace2::x;
What will happen when you attempt to compile and run the following code?
#include
using namespace std;
int main()
{
const char *s;
char str[] = "Hello ";
s = str;
while(*s) {
cout << *++s;
*s++;
}
return 0;
}
A. It will print:"el "
B. The code will not compile.
C. It will print:"Hello "
D. It will print garbage value
What happens when you attempt to compile and run the following code?
#include
using namespace std;
int main()
{
int x,y=10;
float f;
f = 5.20;
x=(int) f;
cout << x <<", ";
f=float (y);
cout << f;
return 0;
}
A. It prints: 5, 10
B. It prints: 5.2, 10
C. It prints: 5.20, 10.0
D. It prints: 5.2, 10.00
What happens when you attempt to compile and run the following code?
#include
using namespace std;
int main(){
int i = 1;
for(i=10; i>-1; i/=2) {
if(!i)
break;
}
cout << i;
return 0;
}
A. It prints: 0
B. It prints: 1
C. It prints: -1
D. Compilation error
What is the output of the program given below?
#include
using namespace std;
int main (int argc, const char * argv[])
{
int i=10;
{
int i=0;
cout<
}
{
int i=5;
cout << i;
}
cout<
return 0;
}
A. 1010
B. 101010
C. 0510
D. None of these
What happens when you attempt to compile and run the following code?
#include
#include
using namespace std;
class A {
int x;
protected:
int y;
public:
int z;
};
class B : public A {
string name;
public:
void set() {
y = 2;
z = 3;
}
void Print() { cout << y << z; }
};
int main () {
B b;
b.set();
b.Print();
return 0;
}
A. It prints: 123
B. It prints: 000
C. It prints: 23
D. It prints: 12
What happens when you attempt to compile and run the following code?
#include
using namespace std;
#define FUN(arg) if(arg) cout<<"Test";
int main()
{
int i=1;
FUN(i<3);
return 0;
}
A. It prints: 0
B. It prints: T
C. It prints: T0
D. It prints: Test
What happens when you attempt to compile and run the following code?
#include
using namespace std;
#define DEF_A 0
int main(int argc, char *argv[]) {
cout << DEF_A;
return 0;
}
A. It prints: 1
B. It prints: 0
C. It prints: ?1
D. Compilation error
What happens if character 3 is entered as input?
#include
class A {
public:
int i;
};
int main () {
int c;
A obj;
obj.i = 5;
cin >> c;
try
{
switch (c)
{
case A. throw 20;
case B. throw 5.2f;
case C. throw obj;
default: cout<<"No exception";
}
}
catch (int e)
{ cout << "int exception. Exception Nr. " << e; }
catch (A e)
{ cout << "object exception. Exception Nr. " << e.i; }
catch (...)
{ cout << "An exception occurred."; }
return 0;
}
A. It prints: object exception. Exception Nr. 5
B. It prints: int exception. Exception Nr.
C. It prints: An exception occurred
D. It prints: No exception
What happens when you attempt to compile and run the following code?
#include
using namespace std;
int main(int argc, char *argv[]) {
char *s = "ABCDEF";
cout << s+2;
return 0;
}
A. It prints: CDEF
B. It prints: ABCDEF
C. It prints: BCDEF
D. None of these
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.