C Plus Plus Miscellaneous - Study Mode
[#611] What will be the output of the following C++ code? #include <iostream>
#include<type_traits>
using namespace std
class Base
{
public:
}
int main()
{
Base b
cout<<sizeof(b)
return 0
}
Correct Answer
(D) 1
[#612] 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 << "
"
}
catch(const char* Message)
{
cout << "Error: " << Message
}
return 0
}
Correct Answer
(A) 5
[#613] 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
}
Correct Answer
(C) Run-time error
[#614] 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])
}
}
Correct Answer
(A) 111110111110
[#615] 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
}
Correct Answer
(C) Both 1 & 2