R
RadiationX
This is the problem that I have to solve :
Write a program to convert a temperature input in Celsius or Fahrenheit
to the other scale. Provide an appropriate prompt, and accept the
temperature input as a double, followed by a char representing the
scale (C or F). Perform the appropriate conversion and display the
original input and result. Write functions ftoc and ctof to do the
conversion and return the result to be displayed in main. The
conversion formulas are as follows, where C is a temperature in degrees
Celsius, and F the equivalent in Fahrenheit:
C = (5.0 / 9.0) * (F - 32)
F = ( (9.0 / 5.0) * C ) + 32
So basically if you enter a temp in Fahrenheit I need to convet it to
Celsius and vice versa.
The user input should be in the form of a double then the scale. For
example
32 F which stands for 32 degrees Fahrenheit. Here is my code so far.
Which compiles but will not execute
#include <stdio.h>
#include <stdlib.h>
double farTemp(double);
double centTemp(double);
int main()
{
double userTemp;
char scale;
char F,f,C,c;
printf("Enter Temp & Scale (F Or C ) ");
scanf("%lf%lf", &userTemp,&scale);
if(scale==f || scale== F)
centTemp(userTemp);
printf("%f", userTemp);
system("PAUSE");
return 0;
}
double CentTemp(double a)
{
return (5.0/9.0)*a -32 ;
}
Write a program to convert a temperature input in Celsius or Fahrenheit
to the other scale. Provide an appropriate prompt, and accept the
temperature input as a double, followed by a char representing the
scale (C or F). Perform the appropriate conversion and display the
original input and result. Write functions ftoc and ctof to do the
conversion and return the result to be displayed in main. The
conversion formulas are as follows, where C is a temperature in degrees
Celsius, and F the equivalent in Fahrenheit:
C = (5.0 / 9.0) * (F - 32)
F = ( (9.0 / 5.0) * C ) + 32
So basically if you enter a temp in Fahrenheit I need to convet it to
Celsius and vice versa.
The user input should be in the form of a double then the scale. For
example
32 F which stands for 32 degrees Fahrenheit. Here is my code so far.
Which compiles but will not execute
#include <stdio.h>
#include <stdlib.h>
double farTemp(double);
double centTemp(double);
int main()
{
double userTemp;
char scale;
char F,f,C,c;
printf("Enter Temp & Scale (F Or C ) ");
scanf("%lf%lf", &userTemp,&scale);
if(scale==f || scale== F)
centTemp(userTemp);
printf("%f", userTemp);
system("PAUSE");
return 0;
}
double CentTemp(double a)
{
return (5.0/9.0)*a -32 ;
}