UP | HOME

Arithmetic Project
COP-3223H

Table of Contents

1. Overview

In this project you will write a program that implements the "always 3" math magic trick.

2. Repository setup

Log into eustis:

ssh NID@eustis.eecs.ucf.edu

Go to your local repository: Be sure you have already completed the git exercise before attempting this project.

cd ~/cop3223spring26/assignments

Create and enter a directory for the arithmetic project:

mkdir arithmetic
cd arithmetic

You only need to mkdir once to create the directory.

Make sure you are in the right directory

pwd

You should see

/home/net/NID/cop3223spring26/assignments/arithmetic

3. Create the math magic program

Make sure you are in the right directory

pwd

You should see

/home/net/NID/cop3223spring26/assignments/arithmetic

You will write a program takes an integer as input and makes the following computations printing each immediate value:

  1. Input an input
  2. Double the inputted number
  3. Add 9 to the result from #2
  4. Subtract three from the result from #3
  5. Divide by two from the result from #4
  6. Subtract the originally inputted number from #1

After each step, print the intermediate value of the number. For instance, if the inputted integer is 14, the output of your program should be (excluding the 14 that you typed into the console):

14
28
37
34
17
3

Only use the C constructs shown in class, specifically

  • The templates for reading integers with scanf and printing integers with printf
  • Integer variable declaration, assignment, and usage
  • The arithmetic operations +, -, *, /.

The program must be called arithmetic.c and must be in the arithmetic directory, i.e., the full path should be

~/cop3223spring26/assignments/arithmetic/arithmetic.c

Compile and run the program whenever you make changes using

cd ~/cop3223spring26/assignments/arithmetic/
gcc -o arithmetic arithmetic.c
./arithmetic

Then enter an integer, hit enter, and observe the output.

4. Submitting your program via git

This assumes you have already setup your repository and that you are still in your hello directory in your repository.

4.1. Add and commit the file

Enter

git add arithmetic.c
git commit arithmetic.c

Write an appropriate commit message. Remember that you will need to save (Ctrl-x Ctrl-s) then quit (Ctrl-x Ctrl-c) the emacs editor that pops up. If you are having trouble, be sure that you have completed the git project first.

Do not commit the backup file arithmetic.c~ nor the arithmetic program. Use a .gitignore file to exclude those from the repository, so they won't show up when you type git status.

Then to synchronize the changes to the remote git repository on the grading server:

git push

5. Self-check

5.1. Remove the previous self-check

If you have already run the self-check, you can remove it like this

rm -rf ~/tmp/assignments_selfcheck

Double-check the path carefully to avoid deleting the wrong directory.

5.2. Make a fresh clone of your project

git clone gitolite3@eustis3.eecs.ucf.edu:cop3223/$USER/assignments ~/tmp/assignments_selfcheck

You should see something like

Cloning into '/home/net/NID/tmp/assignments_selfcheck'...

Welcome to eustis.eecs.ucf.edu.

Please use your NID and NID password to log in.

See http://t.cs.ucf.edu/help/eustis  for additional instructions.

remote: Enumerating objects: 16, done.
remote: Counting objects: 100% (16/16), done.
remote: Compressing objects: 100% (12/12), done.
remote: Total 16 (delta 1), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (16/16), done.
Resolving deltas: 100% (1/1), done.

If you see

fatal: destination path '/home/net/NID/tmp/assignments_selfcheck already exists and is not an empty directory.

then remove the previous self-check.

5.3. Enter the fresh clone's directory

cd ~/tmp/assignments_selfcheck/arithmetic

5.4. Make sure arithmetic runs correctly

cd arithmetic
gcc -o arithmetic arithmetic.c
./arithmetic

Then run the program as described above.

6. Grading schema

Criterion Points
The repo contains arithmetic.c required files 1
The program runs correctly prorated according to test cases 3
TOTAL 4

Author: Paul Gazzillo

Created: 2026-02-02 Mon 01:26

Validate