Numbers


  1. What is the output of this program?
     #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;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    In this program, We are finding the number of decimal points that the type can represent without loss of precision.


  1. Which header file is used for the numeric limits in C++?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    <limits>; header file will be used for numeric limits in C++.



  1. What is the output of this program?
    #include <iostream>
    #include <limits>
    using namespace std;
    int main( )
    {
    cout << numeric_limits<float> :: min_exponent << endl;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    In this program, We are finding the minimum radix of a type by using min_exponent function.


  1. What is the output of this program?
    #include <iostream>
    #include <complex>
    using namespace std;
    int main ()
    {
    complex<double> Comp (10.0, 4.0);
    cout << imag(Comp) << endl;
    return 0;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    imag part will return the imaginary part of the complex number.



  1. What is the output of this program?
    #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;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    In this program, We are finding whether the types are free of rounding errors by using the function is_exact.