C++ LEVEL TEST
About C++ Test
  • There are 10 questions in this C++ test.
  • They cover all levels from basic to advanced in a random order.
  • Some of the questions are easier, some are more difficult. Don’t worry if you don’t know the answer!
  • Don’t use any books or websites to help you – the idea is to find your natural level!

Which of the following is the correct syntax of including a "userdefined" header files in C++?




Which of the following correctly declares an array in C++?




Which is more effective while calling the C++ functions?




Which keyword is used to define the macros in c++?




What is meant by a polymorphism in C++?




Which concept allows you to reuse the written code in C++?




What is the output of the following program?

#include <iostream>

using namespace std;
main() { 
   int *p = new int; 
   delete p; 
   delete p; 
   cout <<"Done";
}



What is the output of the following program?

#include <iostream>

using namespace std;
void swap(int m, int n) {
   int x = m;

	m = n;
	n = x;
}
main() {
   int x = 5, y = 3;
   
	swap(x,y);
	cout <<x <<" " <<y;
}



What is the output of the following program?

#include <iostream>
using namespace std;
  
int main()
{
    char v = 'a';
  
    switch (v) {
    case 'A':
        cout << "Selection is A";
        break;
    case 'B':
        cout << "Selection is B";
        break;
    case 'C':
        cout << "Selection is C";
        break;
    default:
        cout << "Selection other than A, B and C";
        break;
    }
	
    return 0;
}



What is the output of the following program?

#include <iostream>
#include <algorithm>
int main() {
    int arr[] = { 1, 2, 3, 4, 5 };
    int mul = 5;

    std::for_each(arr, arr + sizeof(arr) / sizeof(int), [=](int &x) {
        x= x*mul;
        });

    std::for_each(arr, arr + sizeof(arr) / sizeof(int), [](int x) {
        std::cout <<x<<" ";
        });
    std::cout << std::endl;
}