Floating Point Types

1

Which is correct with respect to size of the datatypes?

A. char > int < float
B. int < char > float
C. char < int < float
D. char < int < double

2

What is the output of this program?

1.
    #include 
2.    
    using namespace std;
3.    
    int main()
4.    
    {
5.    
        float f1 = 0.5;
6.        
        double f2 = 0.5;
7.        
        if (f1 == 0.5f)
8.        
            cout << "equal";
9.            
        else
10.        
            cout << "not equal";
11.            
        return 0;
12.        
    }

A. equal
B. not equal
C. compile time error
D. runtime error

3

Which is used to indicate single precision value?

A. F or f
B. L or l
C. either a or b
D. neither a or b

4

What is the output of the following program?

1.
    #include 
2.    
    using namespace std;
3.    
    int main()
4.    
    {
5.    
        float i = 123.0f;
6.        
        cout << i << endl;
7.        
        return 0;
8.        
    }
A. 123.00
B. 1.23
C. 123
D. compile time error

5

What is the output of this program?

1.
    #include 
2.    
    #include 
3.    
    using namespace std;
4.    
    int main()
5.    
    {
6.    
        cout << setprecision(17);
7.        
        double d = 0.1;
8.        
        cout << d << endl;
9.        
        return 0;
10.        
    }
A. 0.11
B. 0.10000000000000001
C. 0.100001
D. compile time error