COMP 1710 Lecture Notes - Lecture 2: String Operations, Trigonometric Functions, Square Root
Document Summary
Most computer programs hold temporary values in named storage locations (programmers name them for easy access. ) There are many different types (sizes) of storage to hold different things. You declare" a variable by telling the compiler: What type (size) of variable you need. What name you will use to refer to it. When declaring a variable, you often specify an initial value. This is also where you tell the compiler the size (type) it will hold. Each variable has an identifier (name) and contents. You can (optionally) set the contents of a variable when you declare it. Imagine a parking space in a parking garage: Different types of variables used in this chapter: a whole number (no fractional part) int, a whole number with a fractional part double, a word (a group of characters) Specify the type before the name in the declaration. Sometimes when you just type a number, the compiler has to guess" what type it is.