+ 1

Is it all rounded?

I did a question where it's pretty much asked 16Ć·5=that's 3.2 but I would only let me do 1 number so just tryed 3 it worked. If stuff like that is all rounded how would it be reliable?

21st Feb 2022, 5:27 AM
Michael Kreimer
Michael Kreimer - avatar
3 Answers
+ 2
As you progress, you will probably do an exercise that asks for you to reverse a multi digit number, eg 4321 becomes 1234. You can do that with taking the result of modulo 10 šŸ‘‰result=number%10šŸ‘ˆ (4321%10=1) and then shifting the original number to the right by a digit šŸ‘‰number=number/10šŸ‘ˆ ( 4321/10=432) Don't forget to shift your result up a significant figure on each loop šŸ‘‰result=result*10šŸ‘ˆ (1*10=10) If you get that done properly, then checking if a number is pallendromic will be as easy as standing on your head! šŸ™ƒ It seems complicated, but if you takes it one step at a time you will get it. No worries šŸ˜Ž
21st Feb 2022, 6:02 AM
HungryTradie
HungryTradie - avatar
+ 3
What you're doing here is integer/integer division. It just throws away the decimal portion and end up with the integer value. Try changing one of them into a float and see the output. 16/5.0 or 16.0/5
21st Feb 2022, 4:58 PM
Simba
Simba - avatar
+ 1
G'day Michael Kreimer Welcome to being a programmer!! You will learn two different division operations, one is floor division as in your 16/3=5 the other is modulo as in 16%3=1 Modulo gives the remainder of the division, floor division gives the whole number. Good luck mate!!!
21st Feb 2022, 5:55 AM
HungryTradie
HungryTradie - avatar