CODE
/* Fahrenheit to Celsius conversion program, Revision 5 */
/*Filename: week2-pkc.c */
/* This program prompts the user to enter a decimal Fahrenheit temperature to be converted to Celsius */
/*Ask the user to enter a faherinheit temperature to be converted to Celsius */
#include <stdio.h> /*Define data type*/
#include <ctype.h> /*Define data type*/
main()
{
float Fahrenheit; /*Variable to hold Fahrenheit*/
float Celsius; /*Variable to hold Celsius*/
char cAnswer = '\0'; /*Variable to hold yes/no answer*/
printf("Please enter a Faherinheit temperature to be converted to Celsius\n example 82 or 71.5\n");
scanf("%f",&Fahrenheit); /*Get Fahrenheit variable from user input*/
Celsius = (5.00/9.00)*(Fahrenheit - 32); /*Perform calculation to convert fahrenheit to Celsius*/
printf("Fahrenheit = %.2f\nCelsius = %.2f\n , Fahrenheit, Celsius"); /*Print out Fahrenheit number given and the Celsius Equivilant*/
printf("Do you want to enter another temperature, Y or N ?");
scanf("%c",&cAnswer); /*Get answer to enter another temperature*/
if (cAnswer=='Y') {
printf("Please enter a Faherinheit temperature to be converted to Celsius\n example 82 or 71.5\n");
scanf("%f",&Fahrenheit); /*Get Fahrenheit variable from user input*/
Celsius = (Fahrenheit - 32) * (005.00/009.00); /*Perform calculation to convert fahrenheit to Celsius*/
printf("Fahrenheit = %.2f\nCelsius = %.2f\n , Fahrenheit, Celsius"); /*Print out Fahrenheit number given and the Celsius Equivilant*/
}
else {
printf("Press enter to exit");
getchar();
return 0;}
}