100 likes | 238 Views
Memory Concepts in Computer Science. Programmers as Manipulators of Memory!!. What’s a Variable?. A storage place in computer’s memory can change throughout the program’s execution (can vary!!) must declare the variable at beginning of program.
E N D
Memory Concepts in Computer Science Programmers as Manipulators of Memory!!
What’s a Variable? • A storage place in computer’s memory • can change throughout the program’s execution (can vary!!) • must declare the variable at beginning of program
describes what kind of data is going to be stored – called the data type name for the variable Declaring Variables … what happens? Num : integer;
garbage!! Num -12583487 Declaring Variables … what happens? Num : integer; declaration only allocates space in memory!!!
assume user types 35 Assigning values to variables what happens? Num : integer; begin Num := 5; Num := 60; get(num); Num -12583487 5 60 35 only one value at a time can be stored … destructive process!
Num 5 Declaring Variables … what happens? Num : integer:=5; declaration not only allocates space in memory but also places value in there!!!
Lname & * ^ % # @ * ) notice garbage is still in end of string! C h i % # @ * ) C h i % # @ * ) Declaring Variables … what happens? Lname : string(1..8); begin lname(1..3):= “Chi”; put(Lname);
tells how many characters were entered!! Lname & * ^ % # @ * ) only using the characters that were entered!! C h i % # @ * ) Chi Declaring Variables … what happens? Lname : string(1..8); begin get_line(Lname,n); put(Lname(1..n);
Assignment for next class • Read Chapter 1 – Structure of an Ada Program
Some questions to answer: • Describe what is meant by these parts of a program in Ada: • main (executable) block • declaration block • What is the difference in a variable & a constant? • What are reserved words? • What is the source code? • What is the difference in compiling & building a program? • What is syntax error, warning, run-time error, & a logic (application) error? • Why is the USE statement so nice to use?