# CS156: Intro to C, Part I

## Description

For this assignment, you will write a C program called `nums.c`. This program reads two numbers from the user, and produces a few arguably-interesting facts about the numbers. See the example output for the exact output expected from your program.

## Outline

• Display the result of dividing the first number by the second one, using floating-point division. What if the second number is zero? Check the examples.
• Display the numbers in increasing order.
• If either number is thirteen, note that.
• Display which numbers are odd. This one is tricky. Look carefully at the examples, below. What should you print if one is odd and one isn’t? What if both are odd? For the record: 13, 3, and -27 are odd; 6, 18, 0, and -90 are not.

## Examples

Here are a few example runs of the program. The “`% `” is the command prompt, text like this is typed by the user, and the rest is from the program. (You don’t have to make it colored or underlined—that’s just how it looks here, so you can tell who does what.) Don’t be creative about your output—it must look exactly like this (except for the leading spaces):

```    % c11 -Wall nums.c
% ./a.out
A couple of numbers, if you please: 123456 13
Division of 123456 by 13: 9496.615385
In order: 13 123456
Odd: 13
% ./a.out
A couple of numbers, if you please: 1 2
Division of 1 by 2: 0.500000
In order: 1 2
Odd: 1
% ./a.out
A couple of numbers, if you please: 13 -18
Division of 13 by -18: -0.722222
In order: -18 13
Odd: 13
% ./a.out
A couple of numbers, if you please: 0 42
Division of 0 by 42: 0.000000
In order: 0 42
% ./a.out
A couple of numbers, if you please: 0 0
Division of 0 by 0: nope!
In order: 0 0
% ./a.out
A couple of numbers, if you please: -5 0
Division of -5 by 0: nope!
In order: -5 0
Odd: -5
% ./a.out
A couple of numbers, if you please: 13 13
Division of 13 by 13: 1.000000
In order: 13 13
Odd: 13 13
% ./a.out
A couple of numbers, if you please: 301 9
Division of 301 by 9: 33.444444
In order: 9 301
Odd: 301 9
% ./a.out
A couple of numbers, if you please: 9 301
Division of 9 by 301: 0.029900
In order: 9 301
Odd: 9 301
```

## Debugging

If you encounter “STACK FRAME LINK OVERFLOW”, then try this:

```    export STACK_FRAME_LINK_OVERRIDE=ffff-ad921d60486366258809553a3db49a4a
```

## Requirements

• You must turn in the `.c` file; not the binary, not the executable, not the `a.out`.
• We will only test your code with integer input, and their absolute values will be less than one million.
• The division must be performed with double-precision arithmetic.
• The quotient must be displayed with six places after the decimal point.
• You may use only two `int` variables, declared in `main`, in your entire program. No other variables, of any type, are allowed.
• Yes, really.
• We will test your program with several different sets of numbers, not necessarily those listed above.
• You must comment your code appropriately, including your name, date and purpose of the program at the very very very beginning of the file.
• Your output should be exactly the same as the examples above, given the input as specified.

## A Brief Conversation About Requirements

• Adhere to the above requirements, exactly.
• Uppercase/lowercase, spacing, punctuation, etc. must be identical to the samples above.
• The grading software will flag any deviations and points will be deducted.
• Originality is not rewarded.

## How to submit your homework:

Use web checkin, or:

```    ~cs156/bin/checkin HW1 nums.c
```

## How to receive negative points:

Turn in someone else’s work.

• Our grading software compares student submissions for similarity, including obfuscation.
• Sharing ideas and talking about the assignment or the C language is good. That is part of learning.
• Sharing your code or viewing each other's screens is not.

User: Guest

Check: HTML CSS
Edit History Source

Modified: 2018-02-23T19:43

Apply to CSU | Contact CSU | Disclaimer | Equal Opportunity
Colorado State University, Fort Collins, CO 80523 USA