adplus-dvertising
frame-decoration

Question

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

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: (a).y=(int)(x+0.5)

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What is the correct way to round offx, a float, to an int value?

Similar Questions

Discover Related MCQs

Q. By default, any real number in 'C' is treated as

Q. To print out a and b given below, which printf() statement would you use?

float a = 3.14;
double b = 3.14;

Q. When a variable of data type double is converted into float, then

Q. The library function sqrt operates on a double precision argument. If, i is an integer variable, then which of the following calls would correctly compute sqrt(i)?

Q. The statement 

  printf( " % f ", ( float )9/5) ;

prints

Q. The declaration

enum cities{ bethlehem, jericho, nazareth = 1, jerusalem }

assigns the value 1 to

Q. Integer division in a 'C' program results in:

Q. In a 'C'expression involving || operator, evaluation

Q. In C programming language, which of the following operators has the highest precedence?

Q. If i j,k are integer variable with values 1,2,3 respectively, then what is the value of the expression

!((j + k) > (i + 5))

Q. The expression a << 6 shifts all bits of a six places to the left. If a Ox6db7, then what is the value of a << 6

Q. The expression 5 - 2 - 3 * 5 - 2 will evaluate to 18, if - is left associative and

Q. Choose the correct statements

Q. In an operation involving || operator, evaluation

Q. Pick the operators that assosciate from the left

Q. Pick the operators that assosiate from the right

Q. The operators . ,  || , < , = , if arranged in the ascending order of precedence reads

Q. Pick the operators that assosiate from left to right

Q. Pick the operators whose meaning is context dependent

Q. Which of the following comments about the ++ operator are correct ?