Introduction to Programming - PowerPoint PPT Presentation

1 / 11
About This Presentation
Title:

Introduction to Programming

Description:

Lewis & Loftus, or Savitch. CS 100. Lecture 1. 2. Problems and Algorithms ... ( Start next week) Reading: Lewis & Loftus, Chapter 1. Lecture (Tuesday): Kimball B11 ... – PowerPoint PPT presentation

Number of Views:39
Avg rating:3.0/5.0
Slides: 12
Provided by: Mill1
Category:

less

Transcript and Presenter's Notes

Title: Introduction to Programming


1
Introduction to Programming
  • What is an algorithm?
  • Input and output
  • Sequential execution
  • Conditional execution
  • Reading
  • Chapter 1 in either text
  • Lewis Loftus, or Savitch

2
Problems and Algorithms
  • problem A task to be performed
  • algorithm A procedure for solving a problem
  • Algorithms are
  • precise and unambiguous
  • methodical and effective
  • abstract

3
Sample Problems
  • Is a given integer even or is it odd?
  • For each integer in a list, is it even or odd?
  • Play tic-tac-toe so you never lose
  • Play tic-tac-toe so you always win
  • Play chess so you always win

4
Programs and Computers
  • program An algorithm written down in some
    language, e.g., English, Russian, Java, MatLab.
  • computer A device that can execute programs
    written in programming languages, e.g., Java,
    MatLab, C, C, Fortran, Basic.

5
Algorithms and Programs
the thing with the property threeness
6
Problem 1
  • Is a given integer even or odd?
  • more precisely
  • An integer is written on a card. If the integer
    is even, say even, otherwise say odd.

7
Algorithm / Program A
  • 1. Get the integer from the card.
  • 2. Divide the integer by 2.
  • 3. If the remainder is 0, say even, otherwise
    say odd.
  • Test
  • 123456789

8
Algorithm / Program B
  • 1. Get the integer from the card.
  • 2. If the rightmost digit is 0, 2, 4, 6, or 8 say
    even, otherwise say odd.
  • Test
  • MCMXCIX

9
Input and Output
  • input Bring data into the program, e.g., the
    integer from the card.
  • output Send values out from the program, e.g.,
    the text even or odd.

10
Sequential and Conditional Execution
  • sequential execution Perform sequence of
    computation steps in order, e.g., step 1, step 2,
    step 3.
  • conditional execution Perform one of several
    steps based on a test, e.g., either print even
    or print odd based on whether the remainder is
    0 or not.

11
Things to Do Now(if you choose CS100J)
  • Web Browse CS100J web pages
  • http//courses.cs.cornell.edu/cs100j/2002fa/
  • Program 1 get description from web (Homework),
    and start
  • Sections pick one and attend. (Start next week)
  • Reading Lewis Loftus, Chapter 1
  • Lecture (Tuesday) Kimball B11
Write a Comment
User Comments (0)
About PowerShow.com