Sie sind auf Seite 1von 20

Activity 1.

1: Data Containers

Hardware: Physical components that make up a computer. A system of devices, where each device has a specific function.

Software: Instructions that make a computer work. Programs that run in a computer and that make a computer useful to the user.

INPUT DEVICES CPU

OUTPUT DEVICES

RAM MEMORY

SECONDARY STORAGE

Where is the data needed to perform an operation stored? The computer memory stores the information. Data is kept in storage locations in computer memory The memory is divided in addresses, in which the data is stored.

Memory locations (computers working area) that store data whose contents can vary over time, but that hold just one value at any given time. Normally a name is given to them to identify them easily. In programming language are known as variables and they represent a location in the computers RAM memory. A variable is declared depending on the type of data that is going to store.

Data types determine how a data is represented on the computer and the type of processing that the computer can perform over that data. Computers deal with two basic types of data text and numeric. Depending on the computer language the name given to the data type changes, but in general they can be classified in:
o Numeric o String o Boolean

Some languages allow several types of numeric data, a general classification may be (they can be more.). Integer: Positive or negative numbers without fractional part, whole numbers.
o Examples: 4, -125, 15000, -79, 365

Real: Positive or negative numbers with a whole part and a fractional part, (contain a decimal point).
o Examples: -3.56, 765.2342, -56.9, 8.0

Data that holds a group of letters, numbers or special symbols. To assign a value data must be enclosed in quotation marks (single or double). Examples:
o o o o
Hello World! John Doe Broadway 451 8151-4300

Data type that can hold one of two possible values: True or False. Used to select alternative actions (selection).
o Named after George Boole (1815-1864) a famous
English mathematician that described a logical system using variables with only one of two different values.

Depending on the computer language the rules for naming the data containers change, but in general they consider the following rules o Start with a letter o Do not include spaces or special characters. Its also important to use representative names, with a meaning of the data that is being stored. o Base o TotalPayment o IdNumber.

10

To give a value to a data container an assignment symbol (=) must be used followed with the value to assign, that can be an expression. While another value is not assigned, the data container will maintain its original value. Examples: o velocity= distance/ time o tax = salary * .15 o double = number * 2 o score = 100 o name = George Washington
11

12

Which of the following options is NOT a valid name of a variable in any computer language?
a) b) c) d) semestral grade summer2009_grade my_grade califFinCIS100

13

A broad classification of data types is:


a) b) c) d) Internal and External Volatile, constant and temporal Numeric, string and boolean Permanent and temporal

14

Assuming that address is a string variable, which of the following options is a legal assignment statement?
a) b) c) d) e) address = 23Elm 23Elm = address address = 23 Elm address = 23 address = Elm

15

Assuming that salary is a numeric variable, which of the following opitons is a legal assignment statement?
a) b) c) d) e) salary = not enough 25 = salary salary = 23.45 salary = 23.45 None of these

16

Which of the following names seem like good variable names to you? If a name doesnt seem like a good variable name explain why not.
a) b) c) d) e) f) g) c cost CostAmount Cost Amount cstofdngbsns CostOfDoingBusinessThisFiscalYear cost2004

17

If Age and Rate are numeric variables, and Department is a string variable, which of the following statements are valid assignments. Why?
a) b) c) d) e) f)
Age = 23 Age = Rate Age = Departament Age =departament 42 = Age X Rate = 3.5 X X

18

If Age and Rate are numeric variables, and Department is a string variable, which of the following statements are valid assignments. Why?
a) b) c) d) e) f) g) h) Rate = Age X Rate = Departament 6.91 = Rate X Departament = Personal Departament = Personal X Departament = 413 Departament = 413 413 = Departament X

19

Farrell, J. An Object-Oriented Approach to Programming Logic and Design. 2nd ed. Boston, MA:Thomson. 2008. Gladis, T. and Irvine, K. Starting out with Visual Basic 2008. 4th ed. Boston, MA: Addison Wesley. 2009. Schenider, D. I. An Introduction to Programming Using Visual Basic 2008. 7th ed. Boston, MA: Pearson Prentice Hall. 2009

20

Das könnte Ihnen auch gefallen