GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

  GeekInterview.com  >  Interview Questions  >  Programming  >  C

 Print  |  
Question:  Fix Function

Answer: Write the implementation of Fix function? fix(2.5) = 2 and fix(-2.25) = -3, this is the expected result. Write the code to implement this behaviour?


February 02, 2009 04:21:45 #2
 shreeshavailaya   Member Since: February 2009    Total Comments: 1 

RE: Fix Function
 
int fix(float n){if(n<0.0) return n-1;return n+1;}//converted to int by implicit casting
     

 

Back To Question