+ 1
How to divide two integers?
3 Antworten
+ 5
In Python, the integer division operator is //
+ 3
In what language?
Your profile says you are learning C and Java, so here:
C:
int x = 8;
int y = 4;
int z = x / y;
printf("%d", z);
Java:
int x = 8;
int y = 4;
System.out.println(x / y);
0
to add to @sonic
because the question is a bit ambiguous:
// will divide to integers and return an integer but the integer will be rounded down (not towards zero, but down) so negative results such as -3,5 will become -4
it is important to realise the fact that you will lose a part of you value with //