Q581
Open questionSelect an option to see the answer and solution.
Practice every MCQ with options. Use Show answers when you want the correct option and solution.
1,008
Questions
30/51
Page
Pick an option on a question to see the right answer and solution.
Q581
Open questionSelect an option to see the answer and solution.
Q582
Open question#include <iostream>
#include <array>
using namespace std;
int main(int argc, char const *argv[])
{
array<int, 10> arr1 = {1,2,3,4,5};
array<int, 5> arr2 = {6,7,8,9,10};
arr1.swap(arr2);
for(int i=0;i<5;i++)
cout<<arr1[i]<<" ";
cout<<endl;
for(int i=0;i<5;i++)
cout<<arr2[i]<<" ";
cout<<endl;
return 0;
}Select an option to see the answer and solution.
Q583
Open questionSelect an option to see the answer and solution.
Q584
Open question#include <iostream>
using namespace std;
class vec
{
public:
vec(float f1, float f2)
{
x = f1;
y = f2;
}
vec()
{
}
float x;
float y;
};
vec addvectors(vec v1, vec v2);
int main()
{
vec v1(3, 6);
vec v2(2, -2);
vec v3 = addvectors(v1, v2);
cout << v3.x << ", " << v3.y << endl;
}
vec addvectors(vec v1, vec v2)
{
vec result;
result.x = v1.x + v2.x;
result.y = v1.y + v2.y;
return result;
};Select an option to see the answer and solution.
Q585
Open questionSelect an option to see the answer and solution.
Q586
Open questionclass Base
{
public:
virtual void function1() {};
virtual void function2() {};
};
class D1: public Base
{
public:
virtual void function1() {};
};
class D2: public Base
{
public:
virtual void function2() {};
};Select an option to see the answer and solution.
Q587
Open question#include <iostream>
using namespace std;
int main ()
{
char str[] = "Steve jobs";
int val = 65;
char ch = 'A';
cout.width (5);
cout << right;
cout << val << endl;
return 0;
}Select an option to see the answer and solution.
Q588
Open question#include <iostream>
using namespace std;
template <class T>
T max (T &a, T &b)
{
cout << "Template Called ";
return (a > b)? a : b;
}
template <>
int max <int> (int &a, int &b)
{
cout << "Called ";
return (a > b)? a : b;
}
int main ()
{
int a = 10, b = 20;
cout << max <int> (a, b);
}Select an option to see the answer and solution.
Q589
Open question#include <iostream>
#include <string>
using namespace std;
class A
{
int a;
public:
virtual void func() = 0;
};
class B: public A
{
public:
void func(){
cout<<"Class B"<<endl;
}
};
int main(int argc, char const *argv[])
{
A a;
a.func();
return 0;
}Select an option to see the answer and solution.
Q590
Open questionSelect an option to see the answer and solution.
Q591
Open questionSelect an option to see the answer and solution.
Q592
Open questionSelect an option to see the answer and solution.
Q593
Open questionSelect an option to see the answer and solution.
Q594
Open questionSelect an option to see the answer and solution.
Q595
Open question#include <iostream>
using namespace std;
class Base
{
public:
virtual void print() const = 0;
};
class DerivedOne : virtual public Base
{
public:
void print() const
{
cout << "1";
}
};
class DerivedTwo : virtual public Base
{
public:
void print() const
{
cout << "2";
}
};
class Multiple : public DerivedOne, DerivedTwo
{
public:
void print() const
{
DerivedTwo::print();
}
};
int main()
{
Multiple both;
DerivedOne one;
DerivedTwo two;
Base *array[ 3 ];
array[ 0 ] = &both;
array[ 1 ] = &one;
array[ 2 ] = &two;
for ( int i = 0; i < 3; i++ )
array[ i ] -> print();
return 0;
}Select an option to see the answer and solution.
Q596
Open questionSelect an option to see the answer and solution.
Q597
Open questionSelect an option to see the answer and solution.
Q598
Open questionSelect an option to see the answer and solution.
Q599
Open question#include <stdio.h>
int main ()
{
int result;
char oldname[] = "myfile2.txt";
char newname[] = "newname.txt";
result = rename(oldname, newname );
if (result == 0)
puts ( "success" );
else
perror( "Error" );
return 0;
}Select an option to see the answer and solution.
Q600
Open questionSelect an option to see the answer and solution.