What will be the output of the following C++ code? [code] #include <iostream> #include <limits> using namespace std; int

Huỳnh Hiền

New member
What will be the output of the following C++ code?
Code:
    #include <iostream>
    #include <limits>
    using namespace std;
    int main( )
    {
        cout << numeric_limits<float> :: is_exact;
        cout << numeric_limits<double> :: is_exact;
        cout << numeric_limits<long int> :: is_exact;
        cout << numeric_limits<unsigned char> :: is_exact;
    }
A. 0010
B. 0012
C. 1100
D. 0011
 
Answer: d
Explanation: In this program, We are finding whether the types are free of rounding errors by using the function is_exact.
Output:
Code:
$ g++ num2.cpp
$ a.out
0011
 

Tìm kiếm

Back
Top