0% found this document useful (0 votes)
57 views2 pages

Cse 5A Introduction To Programming (C/C++) Homework 2

This document provides instructions for Homework 2 for an introductory C/C++ programming course. Students are asked to write a program that converts temperatures between Fahrenheit and Celsius using given initial variable values and formulas. The program output should match the given example output. Students are to save their source code as hw2.c in their course home directory on the school's servers. The homework is due by October 12 at 6pm.

Uploaded by

cementsaim
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views2 pages

Cse 5A Introduction To Programming (C/C++) Homework 2

This document provides instructions for Homework 2 for an introductory C/C++ programming course. Students are asked to write a program that converts temperatures between Fahrenheit and Celsius using given initial variable values and formulas. The program output should match the given example output. Students are to save their source code as hw2.c in their course home directory on the school's servers. The homework is due by October 12 at 6pm.

Uploaded by

cementsaim
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

CSE 5A

Introduction To Programming (C/C++)


Homework 2
Read Chapter 4 Due: Friday, October 12 by 6:00pm

After logging in, create a new folder/directory in your cs5f Home on ieng9 named HW2 (note uppercase HW2).
You can do this via My Computer -> WebDrive drive W: cs5f..@ieng9 – Home Directory and then create a
New -> Folder and name it HW2.

Using Bloodshed Dev-C++, create a new Source File (File -> New -> Source File) with File Type C Source
Files (*.c), File Name: hw2.c (note lowercase hw2.c). Then Save As in the new W: WebDrive/HW2 folder you
created above (File -> Save As). Feel free to ask the tutors on duty in the lab for help.

HW2/hw2.c will be a program to convert degrees Fahrenheit (F) to degrees Celsius (C) and vice versa. All
variables should be of type double. Here are the initial values for some of the variables.
double F_Degree_1 = 98.60;
double F_Degree_2 = 0.00;
double F_Degree_3 = -4.20;

double C_Degree_1 = -8.35;


double C_Degree_2 = 0.00;
double C_Degree_3 = 100.0;

Use the formulas below to perform the conversions:


C = (F – 32.0) / 1.8 – to convert a Fahrenheit temperature to Celsius
F = C * 1.8 + 32.0 – to convert a Celsius temperature to Fahrenheit

Your output should look exactly like this:


HW2: Temperature Conversions

Converting Fahrenheit to Celsius:


98.60 degrees F = 37.00 degrees C
0.00 degrees F = -17.78 degrees C
-4.20 degrees F = -20.11 degrees C

The sum of 37.00, -17.78, and -20.11 is -0.89


The average of 37.00, -17.78, and -20.11 is -0.30

Converting Celsius to Fahrenheit:


-8.35 degrees C = 16.97 degrees F
0.00 degrees C = 32.00 degrees F
100.00 degrees C = 212.00 degrees F

The sum of 16.97, 32.00, and 212.00 is 260.97


The average of 16.97, 32.00, and 212.00 is 86.99

Use the printf() format specifier %.2f to output all of your double floating point variables with 2 places
precision to the right of the decimal point. Comment your program similar to the last program in Notes #1.

1
No hardcoding of the values above in the code. For example, you cannot use the constant value 98.60
anywhere in your program other than in the initialization of a variable (for example, double F_Degree_1 =
98.60;). You must use variables throughout the program and your printf() statements, not constant numbers.

We will automatically collect your HW2/hw2.c files from your cs5f course specific home directories on ieng9
at 6pm on Friday. Make sure your HW2 project is stored in your cs5f home directory folder. If you have any
questions/problems with this, see one of the tutors or the instructor.

Make sure you have your name and cs5f account number in the header comment of hw2.c.
/*
* Name: Jane-Joe Student
* Login: cs5fXX
* Date: Month Day, Year
* File: hw2.c
* Sources of Help:

* General description of the program ...


*/

I will place a sample executable in the Class Resources / cs5f Public directory under Examples folder

hw2.exe

You might also like