+ 3
How can this programme give this output?
#include <stdio.h> int main() { int i = 2, j = 3, l ; l = j / i * i ; printf( "%d", l) ; return 0; Why does this code return l as 2? Like, how could it possibly ?
4 Answers
+ 10
remember that if you work with integers, you will get integers as a result, the decimals will be ignored. You can also try different results by changing the order of the operation using parentheses, such as: l = j / (i * i);
// Result: 0
+ 7
3/2 = 1
1*2 = 2
+ 4
Yeah I get it now, thanks so much
+ 3
Ohhhh, thanks