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

Fall 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 first.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.

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 first.c
    % ./a.out
    Enter numbers: 21 105
    Your numbers are 21 and 105
    21 divided by 105: 0.200000
    Difference: 84
    Both are divisible by seven.
    % ./a.out
    Enter numbers: 17 12
    Your numbers are 17 and 12
    17 divided by 12: 1.416667
    Difference: 5
    Neither is divisible by seven.
    % ./a.out
    Enter numbers: 14 -3
    Your numbers are 14 and -3
    14 divided by -3: -4.666667
    Difference: 17
    14 is divisible by seven, however, -3 isn't.
    % ./a.out
    Enter numbers: 4 7
    Bad luck!
    % ./a.out
    Enter numbers: 60 0
    Your numbers are 60 and 0
    60 divided by zero: boom!
    Difference: 60
    60 isn't divisible by seven, but 0 is.
    %

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?”
“Dear oh dear.”

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: October 01, 2013, at 12:08 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