CS156: Intro to C, Part I

Spring 2018

My First C Program

Your First C Program                

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                

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
    Bad luck!
    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
    Bad luck!
    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
    Bad luck!
    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                

A Brief Conversation About Requirements                

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.                 

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
© 2018 Colorado State University
CS Building