2 Replies - 454 Views - Last Post: 28 February 2018 - 08:25 PM Rate Topic: -----

#1 azerega   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 15-April 16

Help with homework trying to convert temperatures using functions

Posted 21 April 2016 - 10:17 AM

Hello everyone, I'm wondering if anyone could help me out with my code to make it work like I want to in order to complete the assignment? Attached is the instructions for the homework:
Write the code using functions.
Write a program that gives user menu to choose from
1. Convert temperature input from the user in degrees Fahrenheit to degrees Celsius
2. Convert temperature input from the user in degrees Celsius to degrees Fahrenheit
3. Quit.
Formulae- C = (5 / 9) * (F-32) and F = (9/5) * C + 32
Need to use functions only to accomplish 1 and 2.
Need to use at least two functions for each scenario and need to call them from the main function. Can use
more functions as you see fit.
Test the program with the following values:
68 degree F = 20 degree C
20 degree C = 68 degree F
-22 degree F = -30 degree C
0 degree C = 32 degree F


Here is my code so far, I'm trying to just convert Fahrenheit to Celsius but it's not working:
// Alejandro Zerega
// April 21, 2016
// Assignment 9 

// Preprocessor Directives
#include <stdio.h>
#include <stdlib.h>
#define PAUSE system("pause")


// Prototype & Function Definitions
double farenheitToCelsius(double f, double celsius);
main() {
	printf("1. Farenheit to Celsius\n");
	printf("2. Celsius to Farenheit\n");
	printf("3. Quit.\n");
	int askInput;
	scanf_s("%lf", &askInput);
	double farenheit;
	if (askInput == 1)
		farenheitToCelsius(double f, double celsius);

	PAUSE;
}

double farenheitToCelsius( double f, double celsius) {
	double number, celsius;
	printf("Please input the Farenheit temperature to convert to Celsius\n");
	scanf_s("%lf", &number);
	celsius = (5.0 / 9.0) * (number - 32.0);
	printf("The equivalent temperature of %.2lf degrees Farenheit is %.2lf degrees Celsius\n", number, celsius);
	return celsius;
}



Is This A Good Question/Topic? 0
  • +

Replies To: Help with homework trying to convert temperatures using functions

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14089
  • View blog
  • Posts: 56,440
  • Joined: 12-June 08

Re: Help with homework trying to convert temperatures using functions

Posted 21 April 2016 - 10:20 AM

In what way is it not working?
Was This Post Helpful? 0
  • +
  • -

#3 femrost   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 09-January 18

Re: Help with homework trying to convert temperatures using functions

Posted 28 February 2018 - 08:25 PM

[ rules ][ /rules ]
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1