[Skip Navigation] [CSUSB] / [CNS] / [CSE] / [R J Botting] >> [CSE201] >> [Lab01] >> index
[Index] [Schedule] [Syllabi] [Glossary] [Labs] [Projects] [Resources] [Grading] [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]
Tue Jan 24 11:39:10 PST 2012

# CSci201 Laboratory 04 -- Logic

Previous [ ../lab03/ ] Next [ ../lab05/ ]

## Set up

Login. You need to create a "lab04" directory under your "cs201" directory. Perform all the exercises in this lab under this directory.

## Example of ifs and elses used in class

Download, compile, and test [ ifelses.cpp ] which is like an example you saw in class 05. Try several values. What does it do with multiples of 7?

Change the program so that it correctly describes any number from 2 thru to 49.

## Example from text book of a while loop

Section 3.6 (pages 121-123) presents a problem (when will my investment be worth twice what it is now) and its solution. Here [ doublinv.cpp ] is the code. Download and run this.

The problem is that these days the interest rate is not 5% but 1%. Change the program to find out how long it takes to double the investment today.

## Printing a truth table

Download [ george.cpp ] and compile and run it. Confirm that it outputs a simple truth table. Look at the tricks in the code -- how to use tab characters, how to do bool for loops, how to output Booleans.

This program tests a special case of De Morgan's law (advanced Topic 3.3). Can you change it to test another case?

## Printing a truth table with 3 varaibles

This [ george3.cpp ] is a partial solution to Exercise R3.11 on page 147 of Horstmann and Budd.

What column is missing? Can you change the program to output the missing column?

## To earn credit

Either show the lab instructor the programs or print them and hand the printouts in.

. . . . . . . . . ( end of section CSci201 Laboratory 04 -- Logic) <<Contents | End>>

# Abreviations

1. Gnu::="Gnu's Not Unix", a long running open source project that supplies a very popular C++ compiler.
2. TBA::="To Be Announced", something I have to do.
3. TBD::="To Be Done", something you have to do.