C Plus Plus Miscellaneous - Study Mode
[#631] What will be the output of the following C++ code? #include <iostream>
#include <complex>
using namespace std
int main()
{
complex <double> cn(3.0, 4.0)
cout<<sin(cn)<<endl
return 0
}
Correct Answer
(A) (3.85374,-27.0168)
[#632] What will be the output of the following C++ code? #include <iostream>
#include <limits>
using namespace std
int main( )
{
cout << numeric_limits<float> :: digits10 << endl
cout << numeric_limits<double> :: digits10 << endl
float f = 99999999
cout.precision ( 10 )
cout << f << endl
}
Correct Answer
(D) 6 15 100000000
[#633] Which of the following is the correct way of declaring a tuple?
Correct Answer
(C) tuple <type1, type2, type3> tp
[#634] What will be the output of the following C++ code? #include <iostream>
#include <fstream>
using namespace std
int main ()
{
int length
char * buffer
ifstream is
is.open ("sample.txt", ios :: binary )
is.seekg (0, ios :: end)
length = is.tellg()
is.seekg (0, ios :: beg)
buffer = new char [length]
is.read (buffer, length)
is.close()
cout.write (buffer, length)
delete[] buffer
return 0
}
Correct Answer
(D) Runtime error
[#635] 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, 5, 15}
vector<int> v(myints, myints + 5)
make_heap (v.begin(), v.end())
pop_heap (v.begin(), v.end())
v.pop_back()
v.push_back(99)
push_heap (v.begin(), v.end())
sort_heap (v.begin(), v.end())
for (unsigned i = 0
i < v.size()
i++)
cout << ' ' << v[i]
return 0
}
Correct Answer
(C) 5 10 15 20 99