CISC 3130 — Lab #1

CISC 3130
Data Structures
Lab #1
Basic Imperative C++

How to Develop and Submit your Labs

Make sure you read the sections in the above on how to interpret CodeLab string comparison feedback

Lab 1.1 — Another 'Hello world' program

Write a C++ program to print the following console output:
+----------------------+
| Hello from CISC 3142 |
+----------------------+

  • Simple warm-up for using your development environment and CodeLab

Lab 1.2 — Collatz Sequences

A Collatz sequence is a seqence of numbers generated from a positive integer using two very simple arithmetic operations. To produce the Collatz Sequence of a positive integer:

Here is a simple example … the Collatz sequence for the number 3 is:

3, 10, 5, 16, 8, 4, 2, 1
What is especially interesting is that it appears as if the sequence will keep bouncing around, but invariably, they end up at 1.

The Collatz Conjecture (one of the more famous unsolved math questions) states that every Collatz sequence eventually transforms to 1.

Write a C++ program to prompt for a start value and end value, and print the collatz sequences of the integers in the specified range (inclusive)

Sample Test Run #1

from: 10
to: 20

10, 5, 16, 8, 4, 2, 1
11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1
12, 6, 3, 10, 5, 16, 8, 4, 2, 1
13, 40, 20, 10, 5, 16, 8, 4, 2, 1
14, 7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1
15, 46, 23, 70, 35, 106, 53, 160, 80, 40, 20, 10, 5, 16, 8, 4, 2, 1
16, 8, 4, 2, 1
17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1
18, 9, 28, 14, 7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1
19, 58, 29, 88, 44, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1
20, 10, 5, 16, 8, 4, 2, 1

  • Basic arithmetic, conditionals, and iteration

Lab 1.3 — Processing a List of Names (Approval)

Write a C++ program to do the following:

Notes

Sample Test Run #1

For example if the file names.data contains:

Langsam
Tenenbaum
Arnow
Weiss
Cox
upon program termination, the console output should be:
5 records processed.
the file results.data should contain:
Arnow 1003
Cox 1005
Langsam 1001
Tenenbaum 1002
Weiss 1004
and the exit code should be 0.

Sample Test Run #2

If the file names.data did not exist, the console output should be:

*** Exception *** input file names.data not found
and the exit code should be 1.

Sample Test Run #3

If the file names.data contains more than 50 names, the console output should be:

*** Exception *** array capacity exceeded
and the exit code should be 1.

  • Simple, basic, imperative programming in C++
    • files, arrays, sorting, pro-forma exception-handling
  • This effectively covers the 1115 syllabus in C++