1. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int main()
{
int age=5;
try
{
if (age < 0)
throw "Positive Number Required";
cout << age << "\n\n";
}
catch(const char* Message)
{
cout << "Error: " << Message;
}
return 0;
}
#include <iostream>
using namespace std;
int main()
{
int age=5;
try
{
if (age < 0)
throw "Positive Number Required";
cout << age << "\n\n";
}
catch(const char* Message)
{
cout << "Error: " << Message;
}
return 0;
}2. What will be the output of the following C++ code?
#include<iostream>
#include<any>
#include<string>
using namespace std;
int main()
{
string s = "Hello World";
any var(s);
cout<<any_cast<char*>(var)<<endl;
return 0;
}
#include<iostream>
#include<any>
#include<string>
using namespace std;
int main()
{
string s = "Hello World";
any var(s);
cout<<any_cast<char*>(var)<<endl;
return 0;
}3. Which function is used to get the argument of a complex number?
4. What will be the output of the following C++ code?
#include <iostream>
#include <cctype>
using namespace std;
int main(int argc, char const *argv[])
{
char arr[12] = "Hello World";
for(int i=0;i<12;i++)
{
cout<<(bool)isalpha(arr[i]);
}
}
#include <iostream>
#include <cctype>
using namespace std;
int main(int argc, char const *argv[])
{
char arr[12] = "Hello World";
for(int i=0;i<12;i++)
{
cout<<(bool)isalpha(arr[i]);
}
}5. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
class Car
{
public:
int speed;
};
int main()
{
int Car :: *pSpeed = &Car :: speed;
Car c1;
c1.speed = 1;
cout << c1.speed << endl;
c1.*pSpeed = 2;
cout << c1.speed << endl;
return 0;
}
#include <iostream>
using namespace std;
class Car
{
public:
int speed;
};
int main()
{
int Car :: *pSpeed = &Car :: speed;
Car c1;
c1.speed = 1;
cout << c1.speed << endl;
c1.*pSpeed = 2;
cout << c1.speed << endl;
return 0;
}6. In which type of storage location are the vector members stored?
7. How are many sequences of statements present in c++?
8. Which type of relationship is modelled by Inheritance?
9. Which of the following can serve as random-access iterator?
10. What will be the output of the following C++ code?
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main ()
{
int myints[] = {10, 20, 30, 30, 20, 10, 10, 20};
vector<int> v(myints, myints + 8);
sort (v.begin(), v.end());
vector<int> :: iterator low, up;
low = lower_bound (v.begin(), v.end(), 20);
up = upper_bound (v.begin(), v.end(), 20);
cout << (low - v.begin()) << ' ';
cout << (up - v.begin()) << '\n';
return 0;
}
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main ()
{
int myints[] = {10, 20, 30, 30, 20, 10, 10, 20};
vector<int> v(myints, myints + 8);
sort (v.begin(), v.end());
vector<int> :: iterator low, up;
low = lower_bound (v.begin(), v.end(), 20);
up = upper_bound (v.begin(), v.end(), 20);
cout << (low - v.begin()) << ' ';
cout << (up - v.begin()) << '\n';
return 0;
}Read More Section(C plus plus miscellaneous)
Each Section contains maximum 100 MCQs question on C plus plus miscellaneous. To get more questions visit other sections.
- C plus plus miscellaneous - Section 1
- C plus plus miscellaneous - Section 2
- C plus plus miscellaneous - Section 3
- C plus plus miscellaneous - Section 4
- C plus plus miscellaneous - Section 5
- C plus plus miscellaneous - Section 6
- C plus plus miscellaneous - Section 7
- C plus plus miscellaneous - Section 9
- C plus plus miscellaneous - Section 10
- C plus plus miscellaneous - Section 11
