0
why is this working while the result is not an integer?
public class exer { public static void main(String[] args) { int[] delo = new int[3]; delo[0]=10; delo[1]=3; delo[2]=5; for(int f =1; f<2; f++){ delo[0]/=delo[f]; } System.out.print(delo[0]); } }
4 Réponses
+ 11
Mahdi Ardini
Probably because it is giving out int type after division so they just store the int type and decimal type gets ignored. Also this integer division is very helpful in solving problems.
edit: I just googled ceiling funcn after reading ~ swim ~'s comment, it is different than what is happening. Here the decimal part is getting truncated.
+ 10
Division of int type with an int type returns an integer with no decimal part in java.
so 10/3 is equal to 3 here.
+ 1
Gaurav Agrawal hello and thanks brother. but why has it returned the ceiling?