70 likes | 198 Vues
This guide covers essential programming concepts including what variables are, the rules for naming them, and the implications of garbage values. It explains various data types such as strings, characters, booleans, integers, and reals. Key operators and their precedence (PEMDAS) are discussed, as well as real and integer operations including division and remainder. Special attention is given to mixed-mode expressions where integers and reals interact. Syntax errors are also addressed through practical examples to enhance understanding.
E N D
Last Class (sections 3.4 - 3.6) • What is a variable? • rules for naming variables • garbage values • strings, chars, boolean • rules for naming variables • Integer Variables • example from book • +, -, *
Data Types: Reals • A number that contains a decimal point • can begin with a ‘+’ or a ‘-’ • must have digits on both sides of the decimal • cannot contain • commas • an embedded blank • non-numeric characters • a’+’ or a ‘-’ at the end of the value
Real Operators • +, - • *, / • operator precedence • PEMDAS
Integer Operators • +, - • * • DIV “integer division” • MOD “remainder operator” • operator precedence
Mixed mode • You can assign an integer value to a real variable. The compiler automatically converts the integer into a real (ie. 5 -> 5.0) • You cannot assign a real to an integer. • Mixed mode is when both integers and reals are on the right side of an expression (a real variable must be on the left side).
Section 3.11 • readln
Correcting syntax errors • Go over example in book