[Skip Navigation] [CSUSB] / [CNS] / [CSE] / [R J Botting] / [CSE201] / 02
[Text Version] [Syllabus] [Schedule] [Glossary] [Labs] [Projects] [Resources] [Grading] [Contact] [Search ]
Notes: [01] <02> [03] [04] [05] [06] [07] [08] [09] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20]
Labs: [01] [02] [03] [04] [05] [06] [07] [08] [09] [10]
Wed Apr 3 13:46:12 PDT 2013

Contents


    cs201/02 Introduction to Computer Science

      Previous -- Introduction to course.

      [ 01.html ]

      Admin

        Due in -- Review Question and Answer from Chapter 1

        Linux Tutorial this Friday -- I Hope

      . . . . . . . . . ( end of section Admin) <<Contents | End>>

      Study

        1.1 What is a computer

        Computers are dumb.

        They do precisely what we tell them to, step by step, exactly as they have been told.

        So we have to tell them what to do..... in detail.

        Computers are dumb -- we have to be smart to make them useful.

        To be able to tell them what to do correctly you have to understand how they work.

        1.2 What is programming

        Solving people's problems, exploring new ideas, .... , finding out what is wrong and fixing it.

        1.3 The Anatomy of a Computer

        Some of the things that your programs will do won't make sense unless you grasp these facts.

        Random Fact 1.1 -- ENIAC

        NO. I am not this old. :-) My Ph.D. Supervisor worked on the Brittish EDSAC and my father on TRIDAC (3 D simulations of planes and missiles). And in England one of the first generation machines [ technology-20395212 ] the WITCH is still running...

        1.4 Translating Human readable programs to Machine Code

        Life has got easier since we made the computer translate high level languages into machine code for us.

        1.5 Programming Languages

        We cover 10 languages in 10 weeks in [ ../cs320 ] but in this class all we need is to master the simpler parts of C++.

        Once you have got the ideas and syntax of C++ you will find nearly any other language easier to learn -- the exceptions are in CSCI320.

        1.6 The Evolution of C++

        Random Fact 1.2 -- Standards

        1.7 Becoming familiar with your computer

        What Lab 01 and 02 are about.

        Productivity Hint 1.1

        Keep a back up copy of all your data.

        1.8 Compiling a Simple Program

        Lab 01

        Syntax 1.1 Simple Program

        Memorize this ... or make yourself a blank program that you can copy.

        Common Error 1.1 -- Omitting Semicolons

        Sad but true -- missing a ";" is a common error.

        Almost as common as putting a ";" in the wrong place.

        1.9 Errors

        One of the hardest parts of programming is accepting that we all make mistakes.

        Common Error 1.2 -- Misspelling words

        Correct spelling is important for wizards.

        1.10 The compilation Process

        For most of the programs you will write in cs201 you can type this into a terminal window:
         		Q name.cpp
        or this
         		~dick/bin/Q name.cpp

        1.11 Algorithms

        Here is a sample algorithm [ 02example.html ] and [ 02example.cpp ] a rough translation into C++.

        We can use the CodPad site [ http://codepad.org/ ] to check the program for errors.

        In this class there will be programming projects. You should first write an algorithm. Put it in your program file before you add the C++ code:

         /* Algorithm
         		1. .....
         		2. .....
         ...
         end Algorithm */
        For example see [ project.cpp ] which is a good place to start the projects in this class.

        Note: In many applications we don't need a complex algorithm but we do need to understand what the user wants and how they can get it. For example

        • The user wants the computer to calculate the square root of a positive number.
        • Main Scenario
          1. The user inputs a positive number.
          2. The computer outputs the sqare root.

        • Extension 1a
          1. The user inputs a number less than zero,
          2. The computer outputs an eror message.

        • ...
        This is called a "use case" and in this class can be put at the start of the program to document it's purpose. For example, [ 02ex0.cpp ] (Source code).

      Review Questions

      Do as many of the review exercises on pages 27 thru to 29 as you have time for. Hand in a copy of one question and your answer on a piece of paper with your name on it for me to grade at the start of the class.

      Exercises

      1. Here [ 02exalg.html ] is the algorithm from section 1.11 in the text book. Try executing it by hand.

        Here is the example algorithm [ 02example.html ] , follow it, starting with number set to any positive whole number you like. You may use a calulator. You should use paper and pencil. Work out step by step what it does with your starting value.

      2. What does this [ 02ex1.cpp ] display when compiled and run in our lab or on Codepad? Work it out by hand!

      . . . . . . . . . ( end of section Exercises) <<Contents | End>>

      Next -- Numbers and arithmetic in C++

      [ 03.html ]

      Lab

      [ lab01/ ]

    Abbreviations

  1. Algorithm::=A precise description of a series of steps to attain a goal, [ Algorithm ] (Wikipedia).
  2. Class::=A description of a type of object that includes the data it knows and the functions it can execute.
  3. Function::programming=A selfcontained and named piece of program that knows how to do something.
  4. Gnu::="Gnu's Not Unix", a long running open source project that supplies a very popular and free C++ compiler.
  5. OOP::="Object-Oriented Programming", Current paradigm for programming.
  6. Semantics::=Rules determining the meaning of correct statements in a language.
  7. SP::="Structured Programming", a previous paradigm for programming.
  8. Syntax::=The rules determining the correctness and structure of statements in a language, grammar.
  9. Q::software="A program I wrote to make software easier to develop",
  10. TBA::="To Be Announced", something I should do.
  11. TBD::="To Be Done", something you have to do.
  12. UML::="Unified Modeling Language", industry standard design and documentation diagrams.
  13. void::C++Keyword="Indicates a function that has no return value".

( End of document ) <<Contents | Top