CodeLab 09.18.06

CodeLab 09.18.06 - Code Lab: 09.18.06 Write an arithmetic...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Code Lab : 09.18.06 Write an arithmetic expression that calculates the average of 18 and 46. You may already know that: the average of two numbers is their sum divided by 2 the symbol for division is / , thus 10 divided by 5 is written as 10/5 division has higher arithmetic precedence than addition parentheses ( () ‘s) may be used to override precedence Thus, one correct solution would be: (18+46)/2 Try it—enter the above solution and click the submit button! Even with an exercise as simple as taking the average of 18 and 46 it is still possible to make mistakes. For example: we might forget to use parentheses: 18+46/2 or, we might use the wrong arithmetic operator: (18-46)/2 Try these and see the system feedback. Also try entering some of your own incorrect answers, and see what you get. Again, what makes programming so interesting is that there are also MANY ways to be right. For example, we could reverse the 18 and 46 and still have a correct answer: (46+18)/2 One of the most essential components of all learning is experimentation. Nowhere is this more
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 3

CodeLab 09.18.06 - Code Lab: 09.18.06 Write an arithmetic...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online