16 Answers
New Answer#include <iostream> using namespace std; int main() { int h;cin>>h; float f; f=100*2/h; h=f; if(f>=h+0.5) cout<<h+1; else cout<<h; return 0; }
8/5/2020 9:49:42 AM
Learner16 Answers
New AnswerYes I know it.. it's a type convertion float to int..I just said the raw value of f i.e. 66.67 above :)
Buddy the comparison would be 67>=67.17 which is false.. hence the else case would run :) You have forgot to make 66.67 as 67 in your solution :) hence you are getting wrong output :)
There is no syntax error in your program :) your logic is perfect.. you have forgot to intend / leave space.. between some of the parameters.. and to split in multiple lines :) You can see this https://code.sololearn.com/cIs75Z9uEQ1z/?ref=app
It runs perfectly.. you can take h as 5 and the output should be 40 Try it by writing some were you may get the answer :)
Buddy the comparison would be 67>67.17 which is false.. hence the else case would run :) You have forgot to make 66.67 as 67 in your solution :) hence you are getting wrong output :) Ohk.. pls tell me when we put h=3 then what is the value of f . And.. why....
You can't post homework or quizzes here; no one is going to just give you the answer for anything.
I'm not sure why you need to store a float value into an int variable `h = f;` but I would avoid that due to a possible conversion issue. f=66.66; And.. when i write. h=f; Then .. The value of h is 66. And. I need it.. okk
It runs perfectly.. you can take h as 5 and the output should be 40 Try it by writing some were you may get the answer :) Ohk but when u take. Value.. 3 then f=66.67ohk And h=66; Now 66.67>66.5 So if condition ir true So out put is 66+1=67 But output is 66 why................ Solve it prblm Why.. if condition is not run.... pls explain me briefly
Bro... this is concept which i want 2 tell u There is no 66.67 dude The vale of f is 66 r u getting it.
Yes I know it.. it's a type conversation float to int..I just said the raw value of f i.e. 66.67 above :) There is mistake in this program 😁.
I'm not sure why you need to store a float value into an int variable `h = f;` but I would avoid that due to a possible conversion issue.
Learn Playing. Play Learning
SoloLearn Inc.
4 Embarcadero Center, Suite 1455Send us a message