Code:
#include <stdio.h>
void getInput(int* fahrenheit, int* pounds, int* feet);
void calc(int fahrenheit, int pounds, int feet, double* celsius, double*
meters, double* kilograms, double* kelvin, int* inches);
double calcTemp(int fahrenheit, double* celsius, double* kelvin);
double calcDistance(int feet, double* meters, int* inches);
double calcWeight(int pounds, double* kilograms);
void display(int fahrenheit, int pounds, int feet, double celsius,
double kilograms, double meters, double kelvin, int inches);
int main(void)
{
int fahrenheit, pounds, feet, inches;
double celsius, kilograms, meters, kelvin;
getInput(&fahrenheit, £s, &feet);
calc(fahrenheit, pounds, feet, &celsius, &kilograms, &meters,
&kelvin, &inches);
display(fahrenheit, pounds, feet, celsius, kilograms, meters,
kelvin, inches);
return 0;
}
void getInput(int* fahrenheit, int* pounds, int* feet)
{
printf("\nPlease enter temeperature in Fahrenheit (integer): ");
scanf("%d", fahrenheit);
printf("\nPlease enter a distance in feet (integer): ");
scanf("%d", feet);
printf("\nPlease enter a weight in pounds (integer): ");
scanf("%d", pounds);
}
void calc(int fahrenheit, int pounds, int feet, double* celsius, double*
meters, double* kilograms, double* kelvin, int* inches)
{
calcTemp(fahrenheit, celsius, kelvin);
calcDistance(feet, meters, inches);
calcWeight(pounds, kilograms);
}
double calcTemp(int fahrenheit, double* celsius, double* kelvin)
{
*celsius = (fahrenheit -32) * (float)5/9;
*kelvin = *celsius + 273.15;
}
double calcDistance(int feet, double* meters, int* inches)
{
*meters = (float)feet * 0.3048;
*inches = feet * 12;
}
double calcWeight(int pounds, double* kilograms)
{
*kilograms = (float)pounds * 0.45359237;
}
void display(int fahrenheit, int pounds, int feet, double celsius, double
kilograms, double meters, double kelvin, int inches)
{
printf("\n%13s%9s%14s%9s%14s%14s", "Original", "Value",
"Converted to", "Value", "Converted to", "Value");
printf("\n%13s%9s%14s%9s%14s%14s", "--------", "-----",
"------------", "-----", "------------", "-----" );
printf("\n%13s%9d%14s%9.3f%14s%9.3f", "Fahrenheit", fahrenheit,
"Celsius",celsius, "Kelvin", kelvin);
printf("\n%13s%9d%14s%9.3f%14s%9d", "Feet", feet, "Meters", meters,
"Inches", inches);
printf("\n%13s%9d%14s%9.3f", "Pounds", pounds, "Kilograms",
kilograms);
printf("\n\n");
}