+ 3

#include <iostream> using namespace std; int main() { int x = 15/(3*(5/3)); cout << x; return 0;} D output wz 5 hw

29th Mar 2018, 6:32 AM
JeClives
9 Respuestas
+ 8
parenthesis has highest priority to evaluate and parenthesis are solved most inner to outer so first (5/3) will evaluate and give op 1 because 3 can divide 5 at 1 time so op is 1 and remainder is 2 then(3*(1)) which op as 3 then 15/3 which gives 5 so finally the output is 5
29th Mar 2018, 6:40 AM
GAWEN STEASY
GAWEN STEASY - avatar
+ 2
Oh I get it
29th Mar 2018, 6:42 AM
JeClives
+ 1
The out put of this code was "5" I still don't understand how #include <iostream> using namespace std; int main() { int x = 15/(3*(5/3)); cout << x; return 0; }
29th Mar 2018, 6:33 AM
JeClives
+ 1
because all numbers are int, so 5/3 is 1 3*(5/3) is 3 15/3 is 5
29th Mar 2018, 6:35 AM
🇮🇷 M N
+ 1
Whats the reasoning behind declaring 5/3 as 1 couldn't it then have also declared 15/3 as 1 was it the bracket
29th Mar 2018, 6:38 AM
JeClives
+ 1
But (5/3) ISN'T 1!!!
29th Mar 2018, 6:41 AM
JeClives
+ 1
as i said because all numbers are int 5/3 in calculator is 1.6 and when convert to int will be 1 15/ 3 in calculator is 5 and int of it is 5 too
29th Mar 2018, 6:41 AM
🇮🇷 M N
+ 1
I get it
29th Mar 2018, 6:42 AM
JeClives
0
Lol
1st Apr 2019, 5:06 AM
ASCII
ASCII - avatar