Loading...

C++ Multiple Choice Questions

Our C++ questions and answers focuses on all areas of C++ programming language covering 100+ topics in C++

C++ Arrays & Strings MCQ | Set 3

C++ Arrays & Strings | Set 3


21. Which of the header file is used for array type manipulation?

a) <array>
b) <type_traits>
c) <iostream>
d) std namespace



22. What is the use of is_array() function in C++?

a) To check if a variable is array type or not
b) To check if a variable is 1-D array type or not
c) To check if a variable is 2-D array type or not
d) To check if a variable is 1-D or 2-D array type or not



23. What is the use of is_same() function in C++?

a) To check if a variable is array type or not
b) To check whether two variables have the same characteristics
c) To check if two variable is of array type or not
d) To check whether two variables are different or not



24. What is the use of rank() function in C++?

a) Returns size of each dimension
b) Returns how many total elements can be stored in an array
c) Returns how many elements are in array currently
d) Returns the dimension of an array



25. What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
int main() {
    cout << is_same <int, char> :: value;
    cout << is_same <char [10], char [10]> :: value;
    cout << is_same <char * [10], string]> :: value;

    return 0;
}

a) 011
b) 101
c) 010
d) 110



26. What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
int main() {
    cout << rank <int [10]> :: value;
    cout << rank <char [10] [10]> :: value;
    cout << rank < string [10] [10] [10]> :: value;

    return 0;
}

a) 111
b) 123
c) 321
d) 121



27. What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
int main() {
    cout << is_array <int> :: value;
    cout << is_array <char [10]> :: value;
    cout << is_array <string]> :: value;

    return 0;
}

a) 010
b) 101
c) 001
d) 110



28. Which of the following is correct about extent() function?

a) Returns how many elements are in array currently
b) Returns the size of the 1st dimension
c) Returns how many total elements can be stored in an array
d) Returns the size of a given dimension



29. What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
int main() {
    cout << extent < string [10][20][30], 0> :: value;
    cout << extent < string [10][20][30], 1> :: value;
    cout << extent < string [10][20][30], 2> :: value;

    return 0;
}

a) 101010
b) 102030
c) 302010
d) 102010



30. Which of the following is correct about remove_all_extents() function?

a) Removes the all dimension from an array
b) Removes the first dimension from the left of the array
c) Removes the first dimension from the right of the array
d) Removes the last dimension from the left of the array



- Related Topics