+ 1

Hello! I made a programm in visual studio: ..... int a, b, s=0; a=7; b=5; s=a/b; cout<<s; cin.get(); return 0; when i run, programm show me 7/5=1, why not 1,4? please help

17th Jul 2016, 8:04 PM
Cazmir Raul-Alex
9 odpowiedzi
+ 5
...because you're doing int division. The result is an int.
17th Jul 2016, 8:08 PM
Dorian
+ 2
change all int to double that will work
17th Jul 2016, 11:25 PM
_Geometry dash_ _Roh_ (AKA NovaRate0315)
_Geometry dash_ _Roh_ (AKA NovaRate0315) - avatar
+ 2
int/int returns int, cutting the value to int
18th Jul 2016, 4:38 AM
_Geometry dash_ _Roh_ (AKA NovaRate0315)
_Geometry dash_ _Roh_ (AKA NovaRate0315) - avatar
+ 2
You need to use float or double.
18th Jul 2016, 5:52 PM
Christian Roos
Christian Roos - avatar
+ 1
esti roman?😂😂
17th Jul 2016, 8:12 PM
Cazmir Raul-Alex
+ 1
ca nu inteleg, eu asa am invatat la scoala, doar ca am lucrat in mingw
17th Jul 2016, 8:14 PM
Cazmir Raul-Alex
+ 1
not yet...
17th Jul 2016, 8:16 PM
Dorian
+ 1
ok
17th Jul 2016, 8:19 PM
Cazmir Raul-Alex
+ 1
double s
18th Jul 2016, 11:11 AM
Yaphea Zhang
Yaphea Zhang - avatar