adplus-dvertising
frame-decoration

Question

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: (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. We want to round off x, a float, to an int value, The correct way to do is

Similar Questions

Discover Related MCQs

Q. The binary equivalent of 5.375 is

Q. A float occupies 4 bytes. If the hexadecimal equivalent of these 4 bytes are A, B, C and D, then when this float is stored in memory in which of the following order do these bytes gets stored?

Q. What will you do to treat the constant 3.14 as a float?

Q. Which of the following statement obtains the remainder on dividing 5.5 by 1.3 ?

Q. Declare the following statement?
"An array of three pointers to chars".

Q. What do the following declaration signify?
int *ptr[30];

Q. Declare the following statement?
"A pointer to an array of three chars".

Q. What do the following declaration signify?
char *arr[10];

Q. What do the following declaration signify?
int (*pf)();

Q. Declare the following statement?
"A pointer to a function which receives an int pointer and returns float pointer".

Q. What do the following declaration signify?
void *cmp();

Q. Declare the following statement?
"A pointer to a function which receives nothing and returns nothing".

Q. What do the following declaration signify?
int *f();

Q. What do the following declaration signify?
void (*cmp)();

Q. What do the following declaration signify?
char **argv;

Q. What do the following declaration signify?
char *scr;

Q. An external variable

Q. The declaration "unsigned u" indicates u is a/an

Q. A declaration "short int" is used for variables

Q. Which of the following 'C' type is not a primitive data structure?