4,441 views

2 Answers

0 votes
0 votes
Option C is correct

Option a is wrong -- Since you are rouding off the whole result of addition and not x

Option B is error you cant do this

option d is -- You are converting an x into integer first then after adding with 0.5 you will again get a result as floating value .

and then you are converting this into integer

But they have asked to convert x into integer so option c is correct
0 votes
0 votes
Ans should be  A

lets take x=10.3  so after round off it should be 10

and id x=10.5 after round off it should be 11

now option

A) 10.3+0.5 =10.8 => int(10.8) =10 correct  also 10.5+0.5 =11=> int(11)=11 again correct  

B) incorrect syntax

C)y = (int) x + 0.5 => int (10.3)=10 +0.5  =>   int(10.5) =10 correct but int(10.5)=10+0.5 =10.5=> int(10.5)=10 incorrect  

D)int(int(10.5)+0.5) = int(10+0.5)  =int(10.5)=10 incorrect
Answer:

Related questions

1 votes
1 votes
1 answer
2
go_editor asked Jul 25, 2016
2,619 views
What is the value of the postfix expression a b c d + - * (where a=8, b=4, c=2 and d=5)$-\frac{3}{8}$$-\frac{8}{3}$24-24
2 votes
2 votes
1 answer
3
go_editor asked Jul 25, 2016
2,137 views
Which of the following has compilation error in C?int n=32 ;char ch=65 ;float f=(float) 3.2 ;none of the above
0 votes
0 votes
2 answers
4
go_editor asked Jul 25, 2016
3,165 views
What does the following declaration mean? int (*ptr) [10];ptr is an array of pointers of 10 integersptr is a pointer to an array of 10 integersptr is an array of 1...