Logo

C-and-c- Questions Set 6:

Quiz Mode

What is the other name for run-time polymorphism?

1
2
3
4

Solution:

What is the output of the following code?


#include<stdio.h>


int main()

{

char* s="Abekus";

*(s+2)='a';

printf("%c",s);

return 0;

}

1
2
3
4

Solution:

Which of the following is the correct statement?

1
2
3
4

Solution:

What is the following code calculating?

int function(int a, int b) 

    if (b == 0) 

       return a; 

    return function(b, a % b);  

1
2
3
4

Solution:

What is meant by multiple inheritance?

1
2
3
4

Solution:

 

What will be the output of the following C++ code?

#include <iostream>

using namespace std;

void addprint()

{

static int s = 1;

       s++;

cout << s;

}

int main()

{

       addprint();

       addprint();

       addprint();

return 0;

}


1
2
3
4

Solution:

What will be the output of the following C++ code?

#include <iostream>

#include <functional>

#include <algorithm>

using namespace std;

int main()

{

int numbers[] = {10, -20, -30, 40, -50};

int cx;

cx = count_if(numbers, numbers + 5, bind2nd(less(), 0));

cout << cx;

return 0;

}

1
2
3
4

Solution:

What will be the output of the following C++ code?

#include <iostream>

#include <vector>

using namespace std;

int main()

{

vector<bool> mask;

mask.push_back(true);

mask.flip();

cout << boolalpha;

for (unsigned i = 0; i < mask.size(); i++)

cout << mask.at(i);

return 0;

}

1
2
3
4

Solution:

 

#include <iostream>

#include <functional>

#include <algorithm>

using namespace std;

int main ()

{

int first[] = {10, 40, 90};

int second[] = {1, 2, 3};

int results[5];

       transform ( first, first + 5, second, results, divides<int>());

for (int i = 0; i < 3; i++)

cout << results[i] << " ";

return 0;

}

1
2
3
4

Solution: