+ 2

Why this code does not work?

I have this code in C++Ç if (vurusyukseklik<=0){cout<<"Hedef menzil disinda! \n";} if ((vurusyukseklik>0) && (vurusyukseklik<=0,9)){cout<<"Hedefi bacagindan vurdun! \n";} if ((vurusyukseklik>0,9) && (vurusyukseklik<=1,7)){cout<<"Hedefi govdesinden vurdun! \n";} if ((vurusyukseklik>1,7) && (vurusyukseklik<1,8)) {cout<<"Tam basindan vurdun! \n";} if (vurusyukseklik>1,8) {cout<<"Mermi hedefin uzerinden uctu gitti!";} When my vurusyukseklik value is 1.99983, the program prints out every output except the first one. Why does this happen?

20th Apr 2018, 5:16 PM
Yucuklu Sumurta
Yucuklu Sumurta - avatar
8 Answers
0
Wow i found what is wrong! I was writing decimal numbers with comma, not dot :o
20th Apr 2018, 7:22 PM
Yucuklu Sumurta
Yucuklu Sumurta - avatar
+ 3
Is vurusyukseklik an int? You need to define it float. Or double, if you want more precisity than 5 digits.
20th Apr 2018, 5:21 PM
Timon Paßlick
+ 2
Sry, I can't overview it because I'm so confused by your language.
20th Apr 2018, 5:29 PM
Timon Paßlick
+ 2
XD
20th Apr 2018, 8:03 PM
Timon Paßlick
+ 1
Yucuklu Sumurta you can use else-if ladder in such a condition
21st Apr 2018, 1:13 AM
$¢𝐎₹𝔭!𝐨𝓝
$¢𝐎₹𝔭!𝐨𝓝 - avatar
+ 1
I am not sure bc i dont understand your language
22nd Apr 2018, 8:02 PM
Dayla
0
It is just a simple bullet simulator. It uses x=1/2*a*(t)^2 I tried to translate it: https://pastebin.com/Xwt6GTw2 I do not have problem with the main parts of the code but just with the comparison section ://// Here is the codeplayground link btw: https://code.sololearn.com/c22R8DT9J6H7/#cpp (tufekyukseklik is rifleheight)
20th Apr 2018, 5:41 PM
Yucuklu Sumurta
Yucuklu Sumurta - avatar
0
i just wrote decimal numbers with comma xd
22nd Apr 2018, 8:03 PM
Yucuklu Sumurta
Yucuklu Sumurta - avatar