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;
}

New Topic/Question
Reply


MultiQuote





|