+ 3
Find the error below prgrm....
#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; }
16 Antworten
+ 14
Yes I know it.. it's a type convertion float to int..I just said the raw value of f i.e. 66.67 above :)
+ 13
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 :)
+ 12
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
+ 12
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 :)
+ 4
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....
+ 3
You can't post homework or quizzes here; no one is going to just give you the answer for anything.
+ 3
Ohk.. but i want to know why if statement not run in this prgrm??
+ 3
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
+ 3
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
+ 3
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.
+ 3
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 😁.
+ 2
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.
+ 2
The value of h is 66. And. I need it.. okk
Okk ...
+ 2
Where is the if statement body?
5 line inside the main body and check condition also.
+ 1
its must be c++
+ 1
Where is the if statement body?