Colorado State University

This file defines the header for each page. An optional "icon" image (I use the textbook):

Three headers follow: ! Long name of class !! Semester !!! HW 1, replaced by the name of the current page.

CS156: Intro to C, Part I

Spring 2013

HW 1

Links to the various pages for this class:

Wish I could do this: * Schedule

My First C Program

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

Here’s an outline for the program:

Examples

Here are a few example runs of the program. Underlined text is typed by the user, the “%” is the command prompt, the rest is from the program. (You don’t have to make it 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):

    % c99 nums.c
    % ./a.out
    Firstly: 20
    Secondly: 1957
    Your numbers are 20 and 1957
    20 divided by 1957 makes 0.010220
    Difference: 1937
    Neither is divisible by six.
    % ./a.out
    Firstly: 17
    Secondly: 12
    Your numbers are 17 and 12
    17 divided by 12 makes 1.416667
    Difference: 5
    17 isn't divisible by six, but 12 is.
    % ./a.out
    Firstly: 18
    Secondly: -3
    Your numbers are 18 and -3
    18 divided by -3 makes -6.000000
    Difference: 21
    18 is divisible by six, however, -3 isn't.
    % ./a.out
    Firstly: 60
    Secondly: 0
    Your numbers are 60 and 0
    60 divided by zero makes a problem.
    Difference: 60
    Both are divisible by six.
    % ./a.out
    Firstly: 13
    Secondly: 9
    Bad luck!
    %

Requirements

A Brief Conversation About Requirements

“You’re not serious about only two variables, are you?”
“I'm serious.”
“That can’t be done!”
“Can too.”

“Surely, you don’t mean exactly the same output. Close is good enough, right?”
“No, I mean super-duper-mega-totally-exactly the same.”
“Well, you don’t care about upper/lower case, right?”
“I do care.”
“You can’t take off points for spelling!”
“Sure, I can. Copy what you see in the assignment.”
“Well, you don’t care about spaces, right?”
“I care about spaces, too.”
“What about periods?”
“Those matter, as well.”
“You mean that everything has to be exactly the same?”
“Yes, that’s what I meant to say.”

“What do you mean by the very very very beginning of the file?”
“You’re just trying to get me to have a stroke.”

How to submit your homework:

Follow the directions on the homework page.

How to receive negative points:

Turn in someone else’s work.


Page: Main.HW1
Modified: February 27, 2013, at 08:17 PM
Wiki: pmwiki-2.2.35
CS Department
Apply to CSU | Contact CSU | Disclaimer | Equal Opportunity
Colorado State University, Fort Collins, CO 80523 USA
© 2012 Colorado State University