1.
Introduction to Computers and Programming (Short
Repetition)
Introduction
• Computers can be programmed
– Designed to do any job that a program tells them to
• Program: set of instructions that a computer follows to perform a task
– Commonly referred to as Software
• Programmer: person who can design, create, and test computer programs
– Also known as software developer
1
How Computers Store Data
• All data in a computer is stored in sequences of 0s and 1s
• Byte: just enough memory to store letter or small number
– Divided into eight bits
– Bit: electrical component that can hold positive or negative charge, like on/off switch
– The on/off pattern of bits in a byte represents data stored in the byte
2
Counting
Decimal Binary Calculation
0 0000 0 ∗ 20
1 0001 1 ∗ 20
2 0010 1 ∗ 21 + 0 ∗ 20
3 0011 1 ∗ 21 + 1 ∗ 20
4 0100 1 ∗ 23 + 0 ∗ 21 + 0 ∗ 20
5 0101 1 ∗ 23 + 0 ∗ 21 + 1 ∗ 20
6 0110 1 ∗ 23 + 1 ∗ 21 + 0 ∗ 20
7 0111 1 ∗ 23 + 1 ∗ 21 + 1 ∗ 20
8 1000 1 ∗ 24 + 0 ∗ 23 + 0 ∗ 21 + 0 ∗ 20
0001 is the same as 1, the leading zeros are a convention
3
Storing Characters - Character Sets
• Data stored in computer must be stored as binary number
• Characters are converted to numeric code, numeric code stored in memory
– Most important coding scheme is ASCII
∗ ASCII is limited: defines codes for only 128 characters
– Unicode coding scheme becoming standard
∗ Compatible with ASCII
∗ Can represent characters for other languages
High-Level Languages
• Low-level language: close in nature to machine language
– Example: assembly language
• High-Level language: allows simple creation of powerful and complex programs
– No need to know how CPU works or write large number of instructions
– More intuitive to understand
4
Key Words, Operators, and Syntax: an Overview
• Key words: predefined words used to write program in high-level language
– Each key word has specific meaning
• Operators: perform operations on data
– Example Addition +
∗ 12 + 12
– Example Assignment =
∗ magic_number = 42
• Syntax: set of rules to be followed when writing program
• Statement: individual instruction used in high-level language