How is 15/4 =3?
because 15/4=3.75 but data type is int so only integer part of 3.75 (i.e 3)is displayed neglecting decimal part. if we use float or double then we would have got 3.75
its variable type is int which hold only whole numbers so it records only the 3 and the rest is omitted
The answer depends on the variable and data type you assign to that number. int strictly avoids floating point values (values after decimal.point) so the answer will be just 3. For float and double the answer will be different.
15/4 = 3.75 but if u will assign it's value in int variable then it will only consider 3 neglate the floating point value
change data type from int to double... u will get full answer
cause ur using the initialization of the number as an int which means whole number, you can use double here preferably to get the number in a decimal form or float as well, good luck
4 goes 3 times into 15 and remainder comes 3. that's it. thankx
it is so cuz.... if you will use int a=15;b=4;c=a/b; then you get 3 as a solution. but if you use float c=a/b; then you get the right answer. it is so because int data type only stores the integer values and float stores the integer as well as decimal values also.
Java or C initializes the result into integer if the user doesn't specifies it. for the 15/4 problem, if double a = 15/4 was given, it would give you, 3.75. but since you didn't mention, the data type, java compiler took it as int
convert the result to Integer Integer. parseInt(qoutient);
when u divide these two numbers then it's reminder is 3