SYSC 2006 Lecture Notes - Lecture 3: Decimal Floating Point, While Loop, Return Statement
Document Summary
While loop: header while (fahr <= upper) { Creates a while loop that runs (cid:449)ith the (cid:272)o(cid:374)ditio(cid:374) that the (cid:448)aria(cid:271)le (cid:858)fahr(cid:859) is less than or equal to celsius. The curly brackets opens the body of the loop: body. The body of the loop will run until the conditions of the loop are not satisfied. 5. 0/9. 0: when using division, we much use real numbers(decimals) or else the program will run integer division. 5/9: this will run integer division (5//9 in python) and will return the. The whole of the body must be between curly brackets {body} remainder of the division: return statement return 0. The return specifies which value from the function frame will be brought out to. Assigning a value to a variable: celsius = 5. 0/9. 0*(fahr-32. 0); The right side of the equal sign will be calculated and the value will be stored with the variable name to the right side of the equal sign.