0
(question in C)Help explain to me please.Thanks :)
float a = 0.7; If (0.7 > a){ Printf("hi")}; Else{ Printf("hello")};
6 Respostas
+ 1
Yes Sorry i didnt take a close look anyway the problem is you compare a double with a float
When you write 0.7 without 'f' its actually become a 'double' not a 'float'
If you want to get it right add f to '0.7f' or you could change 'float a' to 'double a'
+ 1
Yahya LAZREK owhhh...thanks alot bro.
0
Is 0.7 > 0.7 ? Actually Not its false So you will get hello .
To get true try :
if(0.7 == a)
0
Yahya LAZREK the answer was hi not hello... that was why I asked cuz it sounded weird for me
0
Because you didn't write the Code Correctly
Look here at line 3 in your Code :
Printf it should be printf and ';' should be after ("hi"); not ("hi")};
The same thing for else and the last line.
Try this :
float a=0.7;
if(0.7 > a)
{
printf("hi");
}
else
{
printf("hello");
}
//it should work propobly
0
Yahya LAZREK yup sorry I had my syntax messed up as I'm still relatively new 😀 but the answer is still hi ...that is the part I don't understand why