CS156: Intro to C, Part I                

Spring 2018                

HW 3                

CS156 HW3: Conversion                


For this assignment, you will write a program called rt.c that does two wildly unconnected things: show the most popular religions and convert temperatures from Fahrenheit to Celsius. (Some religions have hot & cold places—perhaps that connects the two.)                 

Fahrenheit to Celsius                

Religions by popularity                

Here are the ten most popular religions in the world, according to Wikipedia:                 

5Buddhism 6.9%
6Chinese traditional religion 5.50%
7Ethnic religions 4.19%
8African traditional religions 1.40%
9Sikhism 0.32%
10Spiritism 0.21%

Sample Run                

“%” is the prompt and not a part of your program. Your input looks like this. Your output should match exactly.                 

    % c11 -Wall rt.c
    % ./a.out
    q: quit
    h: help
    r: info about a religion
    t: temperature conversion
    Command: t
    Fahrenheit: 212
    212.000000 Fahrenheit is 100.000000 Celsius
    Command: t
    Fahrenheit: 68.5
    68.500000 Fahrenheit is 20.277778 Celsius
    Command: z
    Invalid command
    Command: h
    q: quit
    h: help
    r: info about a religion
    t: temperature conversion
    Command: r
    Which religion? 5
    Buddhism: 6.9%
    Command: r
    Which religion? 3
    Secular/Nonreligious/Agnostic/Atheist: 16%
    Command: r
    Which religion? 100
    Don't know anything about religion #100.
    Command: r
    Which religion? 6
    Chinese traditional religion: 5.50%
    Command: t
    Fahrenheit: 65.5
    65.500000 Fahrenheit is 18.611111 Celsius
    Command: q

Required Functions                

You must define and use the following functions:                 

void print_menu();
Display the help menu, as shown above.
void religion(int);
Display the information about that particular religion. For example, religion(5) would display information about Buddhism. If the number is out of range, display as shown in the sample run.
double celsius(double);
Return the Celsius equivalent of a Fahrenheit temperature.

Note the difference between displaying something and returning something. celsius must not call printf. None of the required functions should call scanf.                 


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

    export STACK_FRAME_LINK_OVERRIDE=ffff-ad921d60486366258809553a3db49a4a


How to submit your homework:                

Use web checkin, or:                 

    ~cs156/bin/checkin HW3 rt.c

Follow the directions on the homework page.                 

How to receive negative points:                

Turn in someone else’s work.                 

Modified: 2018-03-12T11:15                 

User: Guest                 

Edit History Source
Apply to CSU | Contact CSU | Disclaimer | Equal Opportunity
Colorado State University, Fort Collins, CO 80523 USA
© 2015 Colorado State University
CS Building