728by90ad
 
     
				Floating Point Issues - General Questions Multiple Questions and Answers.		
		           
         
        
		   
		       Exercise Questions ::
		       Floating Point Issues
 
| 1. | What are the different types of real data type in C ? | 
		 |  | 
		 | A.  | float, double | 
 | B.  | short int, double, long int | 
 | C.  | float, double, long double | 
 | D.  | double, long int, float | 
 | 
   
    
    
     
    | 
   
		
		    
			    | Answer:  Option  C | 
			
 | 
 | 
		    
 | Explanation: | 
			
		    
		 | 
			  The floating point data types are called real data types. Hence float, double, and long double are real data types.   | 
			
 | See More Information | 
 | 
 | 
		     | 
			 Tutorial Link: | 
			
		
			Published by:Michael Daani 
		 
		
		    
			    | Answer:  Option  C | 
			
 | 
 | 
		    
 | Explanation: | 
			
		    
		 | 
			  Given 3.14 is a double constant. 
To specify 3.14 as long double, we have to add L to the 3.14. (i.e 3.14L)   | 
			
 | See More Information | 
 | 
 | 
		     | 
			 Tutorial Link: | 
			
		
			Published by:Michael Daani 
		 
| 3. | Which statement will you add in the following program to work it correctly? | 
		 | 
#include<stdio.h>
int main()
{
    printf("%f\n", log(36.0));
    return 0;
} 
  | 
		 | A.  | # include < conio.h > | 
 | B.  | # include < math.h > | 
 | C.  | # include< stdlib.h > | 
 | D.  | # include< dos.h > | 
 | 
   
    
    
     
    | 
   
		
		    
			    | Answer:  Option  B | 
			
 | 
 | 
		    
 | Explanation: | 
			
		    
		 | 
			  math.h is a header file in the standard library of C programming language designed for basic mathematical operations. 
Declaration syntax: double log(double);   | 
			
 | See More Information | 
 | 
 | 
		     | 
			 Tutorial Link: | 
			
		
			Published by:Michael Daani 
		 
| 4. | We want to round off x, a float, to an int value, The correct way to do is? | 
		 |  | 
		 | A.  | y = (int)(x + 0.5) | 
 | B.  | y = int(x + 0.5) | 
 | C.  | y = (int)x + 0.5 | 
 | D.  | y = (int)((int)x + 0.5) | 
 | 
   
    
    
     
    | 
   
		
		    
			    | Answer:  Option  A | 
			
 | 
 | 
		    
 | Explanation: | 
			
		    
		 | 
			  Rounding off a value means replacing it by a nearest value that is approximately equal or smaller or greater to the given number. 
y = (int)(x + 0.5); here x is any float value. To roundoff, we have to typecast the value of x by using (int)   | 
			
 | See More Information | 
 | 
 | 
		     | 
			 Tutorial Link: | 
			
		
			Published by:Michael Daani 
		 
		
			Published by:Michael Daani 
		 
	    
»