Welcome Back!


Learning Objectives for Today's Lesson

By the end of today's lesson, you will be able to...
  1. Name and describe the five main components of a computer.
  2. Describe the difference between hardware and software.
  3. Give the definition of an algorithm and write your own algorithms for tasks.
  4. Describe the difference between human and programming languages.
  5. Describe and define a compiler.
  6. Change numbers in the decimal system to the binary system and vice versa.
  7. Open up CodeBlocks and create a new C++ file.


Homework Submission & Waitlist Roll


Logging into the Lab Computers & Catalyst
  • Let's try logging in to Catalyst
  • Catalyst is where you will be submitting all of the rest of your assignments and activities for this class - including today's in-class activities!
  • A Quick Look at Lab 1



A Little Computer Humor

It was everything I expected it would be


Main Components of a Computer

Background Information
  • Computer Science focuses on the design and creation of computer software
  • Computer Engineering focuses on the design and creation of computer hardware.
  • Although we are studying Computer Science (software), it is still important for us to have a general understanding of computer hardware.

Computer Hardware
    • Input device(s) - allow a user to communicate to a computer. Mouse, keyboard.
    • Output device(s) - allow computer to communicate to you. Screen (Monitor), Printer. Speakers.
    • CPU - Central Processing Unit - the "brain" of the computer. Executes programs, performs simple calculations, moves data from one memory location to another.



  • Main memory - Also known as RAM or Random Access Memory. This is the memory that people refer to when they say "How much memory does your computer have?" 
    • Main memory consists of numbered memory locations. Each location in memory is given an "address." The RAM can access each memory location directly by going to that "address." 
    • Think of the RAM as the computer's scratch paper or short term memory. It doesn't store information permanently there. But, uses the memory addresses to temporarily store information it needs as it does its calculations.



  • Secondary memory - This is the permanent memory. The hard disk, CDs, Flash drives, external hard drives. Can you think of anything else?
    • Memory here is stored as files. Secondary memory is generally slower because the computer must search through memory locations sequentially to find a file. Unlike the RAM, the computer cannot access a file directly by its address in secondary memory.

More Information

  • PC World article on the difference between the hard drive (HD) and a solid state drive (SSD)


Group Activity: Where are the different components located on your computer?
  1. Input devices
  2. Output devices
  3. CPU
  4. Main memory
  5. Secondary memory


Computer Software:
    • Program - a sequence of instructions given to a computer. These instructions are executed in order by the Central Processing Unit (CPU).
    • The computer follows the instructions in the program to complete some task.
    • Remember from Hour of Code, the instructions you gave your character were executed in order.



Algorithms
  • Programs are often based on algorithms which are converted into code by the programmer.
  • An algorithm is a sequence of precise instructions on how to accomplish a task
  • The process of developing algorithms is much in demand in today's computerized world
  • For example:
    • Game characters follow algorithms to respond to game events.
    • Medical equipment measures and monitors people's medical conditions following algorithms.
    • Day Traders on Wall Street write computer algorithms to decide when to buy and sell stocks.
  • In everyday life we can develop algorithmic solutions to natural problems and improve our lives.
  • For example, we may develop an algorithm for the easiest or most efficient way to get to school.
  • To develop an algorithm, we start with an analysis and decompose the problem into steps.
  • When we have an algorithm for one problem, we then generalize it to solve similar problems.
  • Examples of algorithms:
    1. A recipe is an algorithm created so others can replicate a dish
    2. When a composer writes music, she is creating an algorithm to play a song
    3. A coach creates a play in a team sport, like football or soccer, which is an algorithm for the players to follow during a game.
    4. In mathematics, people follow algorithms for math operations such as adding numbers with several columns of digits:
      1. Add the numbers in each column
      2. Then add the partial sums

How to Write an Algorithm

  • When we design algorithms, we need to write them simply so anyone can use them
  • This means that we cannot have long formulas or compound statements that are difficult to understand
  • Instead we must break everything down into simple steps
  • Every statement can only say how to do one simple thing
  • A good first approach is to work out an example. Then, try to generalize from the example.
  • As we will see, this is how computers work


Group Activity! Designing Our First Algorithm

Imagine that I have lived a very sheltered life. I grew up with servants waiting on me night and day. I have never even seen the inside of a kitchen. One day, the family fortunes collapsed, and I had to learn to fend for myself. But, how will I feed myself? I don't know how to cook! I don't even know how to make a sandwich! Your task is to teach me how to make a great sandwich. We meet in the kitchen where all the ingredients are available. Tell me what steps I need to follow to make the sandwich. Remember I have never been in a kitchen before, so you will need to give detailed instructions.


Activity 2.1: Designing Our Second Algorithm (10 pts)

  • Now that I have been making so many great sandwiches, I have grown concerned about my weight. I want to calculate my Body Mass Index(BMI) to determine if I fall into the healthy range. The formula for the BMI is as follows:



  • A healthy BMI is between 18.5 and 25. 
  • With a partner, write an algorithm to determine whether I have a healthy BMI. 
  • Open up a new blank document in MS Word.
  • Copy and paste the contents of this worksheet into your blank document.
  • Write both your names at the top and circle the appropriate section.
  • What steps do I need to follow to determine if I am in the normal range?
  • When you are finished, upload your worksheet to Catalyst.
  • Important: Both partners need to submit to receive credit.


Introduction to Programming Languages
  • What are some examples of languages you speak?
    • These languages are used to communicate with people.
  • Programming languages are similar to human languages, but are designed to communicate with machines.
    • Used to communicate instructions to the computer.
  • The problem: Computers only understand 1s and 0s.
  • Difficult for humans to understand 1s and 0s.
  • We need a translator!
  • C++ is a programming language which was created because it is easy for humans to use and understand. It is called a high-level language. Computers cannot understand C++ directly because the instructions are not written in 1s and 0s.
  • Other high level languages include Java, Python, C.
  • Instructions written in these languages are called source code.
  • Programs written in these languages need to be translated into a format the computer can understand.
  • Compiler is a program that translates a high-level language program, such as a C++ program, into a machine-language program that the computer can directly understand and execute.
  • Compilers are also useful because they let you know when you have made certain types of mistakes in your program.


Introduction to Binary Numbers - The Language Computers Understand
  • Video: How Computers Work Part 1
  • Bit = a binary digit = one 0 or 1 digit.
  • Byte = 8 bits
  • Why does a computer understand only 0s and 1s?
  • Understanding Base 10 (Decimal) (on white board)
  • Understanding Base 2 (Binary) (on white board)

Group Activity: Binary Numbers

 I need 5 volunteers to come up to front of the class!

  • Each person will be given a piece of paper with 0 on one side 1 on the other.
  • Then, they will form a line with all 0s facing outward toward the class.
  • We will practice converting numbers from decimal to binary.


Activity 2.2: Binary-Decimal Conversions (10 pts)

  • Find a different person to work with from last time.
  • Open a new document in MS Word and copy and paste the text from from this worksheet into that new document.
  • Write both your names at the top.
  • Select the appropriate section.
  • When you are finished, upload your worksheet to Catalyst.
  • Important: Both partners need to submit to receive credit.


Introduction to C++ - A Language That Humans Can Understand
  • C++ is one of the most popular languages in use today. Please see the Tiobe Community Programming Index for its current ranking.
  • C developed by Dennis Ritchie at AT&T Bell Labs in the 1970s.
  • C++ developed by Bjarne Stroustrup B-yar-ne Strov-stroop at AT&T Bell Labs in the 1980s.
    • 1979 - Stroustrup begins work on "C with Classes"
    • 1982 - Name changed to C++
    • 1983 - First used by AT&T
    • 1985 - First commercial use
  • Let's try writing our first program together! (Done using CodeBlocks)
    • Open Up CodeBlocks by double-clicking the icon on your desktop.
    • Follow my instructions and watch what I am doing up front to create our first C++ program.

Wrap Up
  • With a partner, answer the following questions:
    1. What are the five main components of a computer?
    2. What is the difference between hardware and software?
    3. What is an algorithm?
    4. Why does a computer only understand 1s and 0s?
    5. What is the difference between human and programming languages?
    6. What is a compiler?


Upcoming Assignments
  • Lab 1: Due Friday at midnight on Catalyst.
  • Assignment 2: Due Tuesday at 3:20pm on Catalyst. 
~ Have a Great Weekend! ~