Notes
Outline
CPE 112 – Introduction to Computer Programming
Dr. Rhonda Kay Gaede
UAH
Useful URLs
http://www.ece.uah.edu/cpe112-online
http://www.ece.uah.ece/courses/cpe112
http://www.jbpub.com/dale
Overview of Programming
Programming is telling computers what to do in a language they understand (instructions)
Writing a program is done in two phases:
Problem solving
Analysis & specification
Algorithm
Verification
Implementation
Program
Testing
An algorithm is a step-by-step procedure for solving a problem in a finite amount of time.
Car Starting Algorithm
Insert the key
Make sure the transmission is in Park (or Neutral)
Depress the gas pedal (and clutch)
Turn the key to the start position
If the engine starts within six seconds, release the key to the ignition position.
If the engine doesn’t start in six seconds, release the key, gas pedal (and clutch), wait ten seconds, and repeat steps 3 through 6, but not more than five times.
If the car doesn’t start, call the garage.
What is Programming?
Algorithms get translated into computer programs.
A programming language is a simplified (not necessarily easy to use) form of English that adheres to a strict set of grammatical rules.
Algorithms may be translated
into different languages
by different people in different ways (styles)
Documentation is an important part of the programming process.
Computer Terms & Definitions
Machine language – sequences of 1s and 0s one computer understands
Assembly language – low-level language (closer to human understanding) translated to one machine language by an assembler
High-level language – language close to English (C++ is one of them) which may be translated to many different machine languages by compilers
Control Structures
Sequential Processing (default)
Selection (pick one of multiple choices)
Loop (do things again and again)
Subprogram (pass control over to another piece of code)
Ethics and Responsibilities in the Computing Profession
Software Piracy – It is illegal to copy software without the permission of its creator.
Privacy of Data – A computing professional has a responsibility to avoid taking advantage of special access that he or she may have to confidential data.
Use of Computer Resources – Computing professionals have an ethical responsibility never to use computer resources without permission.
Software Engineering – Programmers have a responsibility for developing software that is free from errors.
Helpful UNIX Commands
Change Directory cd  <directory name>
e.g.  cd  MYDOC (change to directory MYDOC)
        cd                (change to the home directory)
          cd  ..           (change to the parent directory)
List content of current directory          ls
     e.g.   ls MYDOC
 Display current working directory      pwd
 Make a new directory        mkdir <directory name>
 Delete a directory    rmdir <directory name>
Helpful UNIX Commands (Continued)
Rename a file mv <source>  <destination>
       e.g. mv  myfile.cpp dinner.cpp
Delete a file     rm <filename)
Copy a file       cp <source>  <destination>
Compile a file    CC  <source> -o <destination>
       e.g.  CC dinner.cpp –o dinner
       (CC is capital and o is lower case)
 Shortcut to repeat a command   !<first character of previous command>
        e.g. !C to repeat the CC compile command
General Information
Always create a new directory to place all downloaded files, move all files to this directory, and your working directory to it.
Create new files using the text editor available from the graphical interface.
To go to the line where there is a compiler error, in the editor window click on options in menu and select status line.  To go a line, just type in the line number in the box and enter.
Machines are available for your use in eb246, eb 216, and S122 in Tech Hall.