Intro to C++ class Labs

Lab 1.2

Compiling a Program

Familiarity with

15 min.

7

with a Syntax Error the environment

Finished Lab 1.1

continues

L E S S O N S E T

1

Introduction to Programming and the Translation Process

PURPOSE 1. To become familiar with the login process and the C++ environment used in the lab

2. To understand the basics of program design and algorithm development

3. To learn, recognize and correct the three types of computer errors:

syntax errors run time errors

logic errors

4. To learn the basics of an editor and compiler and be able to compile and run existing programs

5. To enter code and run a simple program from scratch

PROCEDURE 1. Students should read the Pre-lab Reading Assignment before coming to lab.

2. Students should complete the Pre-lab Writing Assignment before coming to lab.

3. In the lab, students should complete Labs 1.1 through 1.4 in sequence. Your instructor will give further instructions as to grading and completion of the lab.

1

2 LESSON SET 1 Introduction to Programming and the Translation Process

Lab 1.3

Running a Program with a Understanding of 15 min. 8

Run Time Error the three types

of errors

Lesson 1B

Lab 1.4

Working with Logic Errors Understanding of 15 min. 9

logic errors

Lab 1.5

Writing Your First Program Finished Labs 30 min. 11

1.1 through 1.4

P R E – L A B R E A D I N G A S S I G N M E N T

Computer Systems

A computer system consists of all the components (hardware and software)

used to execute the desires of the computer user. Hardware is the electronic phys-

ical components that can retrieve, process and store data. It is generally broken

down into five basic components:

Central Processing This is the unit where programs are executed. It

Unit (C.P.U.) consists of the control unit, which oversees the

overall operation of program execution and the

A.L.U. (Arithmetic/Logic Unit), which performs the

mathematical and comparison operations.

Main Memory The area where programs and data are stored for

use by the CPU

Secondary Storage The area where programs and data are filed (stored)

for use at a later time

Input Devices The devices used to get programs and data into the

computer (e.g., a keyboard)

Output Devices The devices used to get programs and data from the

computer (e.g., a printer)

Software consists of a sequence of instructions given to perform some pre-defined

task. These labs concentrate on the software portion of a computer system.

Introduction to Programming

A computer program is a series of instructions written in some computer lan-

guage that performs a particular task. Many times beginning students concentrate

solely on the language code; however, quality software is accomplished only

after careful design that identifies the needs, data, process and anticipated out-

comes. For this reason it is critical that students learn good design techniques

before attempting to produce a quality program. Design is guided by an algo-

rithm, which is a plan of attacking some problem. An algorithm is used for

many aspects of tasks, whether a recipe for a cake, a guide to study for an exam

or the specifications of a rocket engine.

Problem example: Develop an algorithm to find the average of five test grades.

Pre-lab Reading Assignment 3

An algorithm usually begins with a general broad statement of the problem.

Find the average of Five Test Grades

From here we can further refine the statement by listing commands that will

accomplish our goal.

Read in the Grades Find the Average Write out the Average

Each box (called a node) may or may not be refined further depending on its

clarity to the user. For example: Find the Average may be as refined as an

experienced programmer needs to accomplish the task of finding an average;

however, students learning how to compute averages for the first time may

need more refinement about how to accomplish the goal. This refinement

process continues until we have a listing of steps understandable to the user to

accomplish the task. For example, Find the Average may be refined into the fol-

lowing two nodes.

Leave a Reply

Your email address will not be published.