[Updated] Goldman Sachs Aptitude Test Questions and Answers
Practice List of TCS Digital Coding Questions !!!
Take 50+ FREE!! Online Data Interpretation Mock test to crack any Exams.

C Programming :: Declarations and Initializations - Discussion

Home > C Programming > Declarations and Initializations > MCQs Questions Discussion

11 / 54

Choose the correct option.

What is the correct way to round off x, a float, to an int value?

Ay = (int)(x + 0.5);

By = int(x + 0.5);

Cy = (int)x+ 0.5;

Dy = (int)((int)x + 0.5);

Answer: Option (Login/Signup)

Show 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)

Asked In ::

Post Your Answer Here:     

Reply    
Rate This: +1 -0 +
    Report


Report Error

Please Login First Click Here

Reply    
Rate This: +0 -0
    Report


Report Error

Please Login First Click Here