Gold University of Minnesota M. Skip to main content.University of Minnesota. Home page.
 
 
 

What's inside.

Ta Email

Day Class Notes

Download Compiler

Evening Class Notes

Lab Notes

Linux For Windows

Office Hours

Schedule

Syllabus

Announcements

Check Grades

 

CSci 1113 Home

 
 

Printer-friendly version

 
Lab Notes

Here's where you will find information on the lab assignments.  The actual assignments are handed out at the beginning of each lab in hard copy form.

Note: the latest lab will be listed first

Lab 11 - This lab will cover pointers, the vector<T> classes, and class inheritance.  It will be useful to study the the example that derives the Cylinder class from the Circle class.

Lab 10
-  Friend functions and operator overloading will be included in this lab, along with character arrays and the string class.  Here is a string class summary document that you may find useful.

Lab 9
- This lab will be on structs and classes.  Note that the Quadratic class from this lab will be extended in Lab 10.  There will also be one more 2D array problem.  The results of this problem will be saved to a file and visualized using Matlab.

Lab 8
- This week's assignment will involve one- and two- dimensional arrays and matrices.  You will use the matrix multiply function matMult.   Here is data for the power plant problem (C) in case you need it.

Lab 7
- This week you will program the secant method, a root-finding algorithm similar to the Newton-Raphson method (the example is from the day class).  You will also do several file I/O problems.  Reviewing the material in Sections 12.1 and 12.2 of the text will be useful. Finally, there is one more interesting (i.e., fun!) problem using random numbers.

Lab 6 - This lab will include the use of the random number generator functions rand() and srand().  Please see the discussion on pages 97-101 of the text and the posted examples. 

There will also be problem using a recursive function.  Here is a description of recursive functions that you should read before doing problem F.

Lab 5
- This lab covers functions, including the use of the return statement, and using call-by-value and call-by-reference to exchange information between a calling function and a called function.

Lab 4
- This lab continues exploration of control structures for branching (multiway if-else, switch statements) and looping (for statement).  Here is a website describing Roman numerals that will be useful.

Lab 3 - This assignment will involve control structures for branching (if, if-else statements) and looping (while, do-while statements).

Lab 2
-  This assignment will explore data types and arithmetic operations.  

Representation of Integers

Here's the information on how integers are stored in the computer:

To represent  positive and negative integers using an 8-bit byte, the two's complement method is used.  In this method, the right-most bit represents 2 raised to the zero'th power, the next bit to the left represents 2 raised to the first power, and so on.  Finally, the left-most bit represents 2 raised to the seventh power (128) times ( -1).  Thus,  an eight-bit value box used for two's-complement representation of integers is

      |-128 | 64 | 32 | 16 |  8 |  4 |  2 |  1 |
     ------------------------------------------
     |     |    |    |    |    |    |    |    |

To get the value of an integer from its bit pattern, simply fill in the box and add the numbers where the ones appear:

For example, the pattern 10001000

        |-128 | 64 | 32 | 16 |  8 |  4 |  2 |  1 |
     ------------------------------------------
     |  1  |  0 |  0 |  0 |  1 |  0 |  0 |  0 |

 gives -128 + 8 = -120

C++ actually uses integers with two or more bytes for storage, but the principle is the same.

+

Loss of Significance When Subtracting Nearly Equal Floating Point Numbers

When two floating point numbers, very close to each other, are subtracted there can be a loss of significant digits in the result.  This is called subtractive cancellation.  For example, if x = 1.23457 and y = 1.23456, then x - y is 0.00001.  When normalized as in the floating point  exercise presented in class (see the day class notes), the result is 1.00000 x 10-5.  The added zeros are not significant, however.  This result has only one significant digit.  Furthermore, if these numbers were to be represented on a computer with only 4 digits in the mantissa, the result would be 0, i.e., the one significant digit would be lost.

Representing Characters in C++

Characters are represented using the ASCII character set that associates an integer with each character.  The ASCII character set is also given in Appendix 3 of the Savitch text.


Lab 1 -
In this lab you will write your first C++ programs.  One of the short answer questions asks about errors.  There are three types of errors that will be encountered in programming:

Syntax error -  a mistake in the syntax of the C/C++ language occurred in the source code.  This error will generate a compiler message; no executable (a.out) file will be produced.

Run-time error - the program compiles without error and produces an executable file.  Whe the program is run it fails to run to completion. Some kind of error message will be produced.  Trying to divide by zero or to take the square root  of a negative number causes a run-time error.

Logic error - the program compiles and runs to completion but produces incorrect results.  One cause of a logic error is to use an incorrect equation in the algorithm being coded. The incorrect result is noticed by comparison to test cases that have known, correct results.


Lab 0 -
In this assignment you are to work through the exercises in the UNIX "Quick Start" Guide and then do the lab problem in the assignment handout.  You  should also go through the tutorial "Everything You Need to Know About UNIX for CSci 1113" which will be handed out in lab. The tutorial is also available here in PDF format: UNIX Tutorial Part 1 and UNIX Tutorial Part 2.

Note:

When using the systems in EE/CS 4-250 you may get a "file not found message" when you try to use the g++ compiler.  If this happens enter the following command:

      module load soft/egcs/4.1

You can enter the following command so that the g++ compiler is automatically available when you logon to any of the ITLabs computers:

     module initadd soft/egcs/4.1
 
The University of Minnesota is an equal opportunity educator and employer.
CSci 1113: C++ Programming