Download presentation
Presentation is loading. Please wait.
Published byPosy Harrison Modified over 9 years ago
1
COP 2510 Programming ConceptsAlessio Gaspar BSAS Industrial Operations 1 Manipulating Data Concepts Covered: Literal values, variables and Types Variables declarations Variables assignments Input / Output operations Statements Part 1 Module 1
2
COP 2510 Programming ConceptsAlessio Gaspar BSAS Industrial Operations 2 Manipulating Data Concept: Literal values
3
COP 2510 Programming ConceptsAlessio Gaspar BSAS Industrial Operations 3 Give me some examples of values you might use in everyday life:
4
COP 2510 Programming ConceptsAlessio Gaspar BSAS Industrial Operations 4 These are possible answers to the previous question… 20ft 32˚F 103.27cm 6.02. 10 23 "Alessio Gaspar" "COP 2510 Programming Concepts" We can easily categorize them: –Numerical value, Strings, … –This leads us to the concept of data type
5
COP 2510 Programming ConceptsAlessio Gaspar BSAS Industrial Operations 5 Manipulating Data Concept: Data Types
6
COP 2510 Programming ConceptsAlessio Gaspar BSAS Industrial Operations 6 Numerical Integer numbers in base 10 Integer numbers in other bases (octal, hexadecimal, binary) Floating point numbers in decimal notation Floating point numbers in scientific notation Strings 20ft 32˚F 103.27cm 6.02. 10 23 "COP 2510 Programming Concepts" Values belong to different TYPES
7
COP 2510 Programming ConceptsAlessio Gaspar BSAS Industrial Operations 7 Numerical –Integer numbers in base 10 –Integer numbers in other bases (octal, hexadecimal, binary) –Floating point numbers in decimal notation –Floating point numbers in scientific notation Strings Values belong to different TYPES
8
COP 2510 Programming ConceptsAlessio Gaspar BSAS Industrial Operations 8 Value String Numerical Integer Floating Point Numerical Integer numbers in base 10 Integer numbers in other bases (octal, hexadecimal, binary) Floating point numbers in decimal notation Floating point numbers in scientific notation Strings Values belong to different TYPES
9
COP 2510 Programming ConceptsAlessio Gaspar BSAS Industrial Operations 9 Value String Numerical Integer Floating Point This view of types is a little “raw” Numerical –Integer numbers in base 10 –Integer numbers in other bases (octal, hexadecimal, binary) –Floating point numbers in decimal notation –Floating point numbers in scientific notation Strings Values belong to different TYPES
10
COP 2510 Programming ConceptsAlessio Gaspar BSAS Industrial Operations 10 Value String Numerical Integer Floating Point This is closer to the kind of “types” we use everyday in real life Numerical –Temperatures –Distances –Duration –Quantity Strings –Employee Last Name –Street Name –Whole Address Values belong to different TYPES
11
COP 2510 Programming ConceptsAlessio Gaspar BSAS Industrial Operations 11 Valid Ranges –Smallest / biggest possible value –E.g. $1,000,000 in a bank account is suspicious for me –E.g. -273 Celsius degrees on your thermometer is suspicious too Encodings –0010 is binary for the decimal value 2 –3 is decimal for 0011 in binary –A is hexadecimal for 10 Value String Numerical Integer Floating Point (more about this later…) Values can have a meaning (“semantics”) which dictates characteristics such as:
12
COP 2510 Programming ConceptsAlessio Gaspar BSAS Industrial Operations 12 Literal value: i.e. How do we write a value in a computer program? –10 vs. 10.0 –20.3 –“what are you doing in my swamp?” –0xA same as 10 s.a. 011 s.a. 1010 Idea of type –Integer number: short, int, long… –Floating point number: float, double, long double… –Single character: ‘a’ –String: “this is a string” –Each with SYNTACTICAL notations and range values When manipulating data in a computer, we capture some of these everyday life practices “some” not “all” Values in a program are typed in a formal way We’ll see very soon why it is so…
13
COP 2510 Programming ConceptsAlessio Gaspar BSAS Industrial Operations 13 Manipulating Data Summary: Literals and Data Types
14
COP 2510 Programming ConceptsAlessio Gaspar BSAS Industrial Operations 14 What we have so far Literal values can be written in computer programs by following some syntactical conventions These values belong to data types which the programming language can manipulate and, as such, have characteristics such as the range of possible values, the lowest value, the highest value…
15
COP 2510 Programming ConceptsAlessio Gaspar BSAS Industrial Operations 15 So… We can imagine that programming languages will allow us to write operations on these values E.g. Compute 2 + 2 The results can be –Displayed / written to disk / sent over the internet to another program… But… what about applications which need to keep results of previous operations handy? –A word processor keeps the text you’re writing in memory somewhere until you close the application –A budget software will store your expenses, compute their sum, keep the value of your balance in memory We need to introduce another programming concept… variables
16
COP 2510 Programming ConceptsAlessio Gaspar BSAS Industrial Operations 16 Manipulating Data Concept: Variables
17
COP 2510 Programming ConceptsAlessio Gaspar BSAS Industrial Operations 17 What is the purpose of a variable? To Store data More specifically, each variable stores one value at a time This allows you to use the result of a computation later on
18
COP 2510 Programming ConceptsAlessio Gaspar BSAS Industrial Operations 18 How do programming languages let you use variables in your programs? Assigning values to variables Here are examples of different syntax that have been used over the years in various languages: A := 2 + 3 A 2 + 3 A = 2 + 3
19
COP 2510 Programming ConceptsAlessio Gaspar BSAS Industrial Operations 19 How do programming languages let you use variables in your programs? Assigning values to variables Here are examples of different syntax that have been used over the years in various languages: Variable Name Assignment Operator Expression Resulting in a Value Generic Syntactical Diagram: A := 2 + 3 A 2 + 3 A = 2 + 3
20
COP 2510 Programming ConceptsAlessio Gaspar BSAS Industrial Operations 20 Doing i/o operations with variables Displaying the value of a variable on the screen Displaying the result of an expression combining variables and literal values on the screen Reading a value from the user (keyboard) and storing it in a variable How do programming languages let you use variables in your programs?
21
COP 2510 Programming ConceptsAlessio Gaspar BSAS Industrial Operations 21 What is a variable in a computer program? The 2 last items relate to the idea of encoding An identifier (a name) to refer to it more easily than by having to specify the memory address at which it’s located A TYPE which determines - How much memory is needed to store the value - How to read this value Some space in memory to store a value in it –SIZE of this memory space –ADDRESS at which it’s located
22
COP 2510 Programming ConceptsAlessio Gaspar BSAS Industrial Operations 22 All this can be specified when declaring variables The idea of TYPE is related to how values are stored in computer memory Declaring Variables
23
COP 2510 Programming ConceptsAlessio Gaspar BSAS Industrial Operations 23 All variables we discussed so far can hold only a single value at a time We will discuss in an upcoming module how we can group values together in aggregate variables Going a little further: Grouping Variables?
24
COP 2510 Programming ConceptsAlessio Gaspar BSAS Industrial Operations 24 Statements We saw some examples of statements: Declare a variable Assign a value to a variable Now what? Learning to program, regardless of the programming language, will require us to get familiar with typical available statements
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.