a) Define a function called convertTempC() . The function should have a paramete
ID: 3551731 • Letter: A
Question
a) Define a function called convertTempC(). The function should have a parameter that will be used to accept temperatures in degrees Celsius. The function should return the converted temperature in degrees Fahrenheit. The formula is [ Fahrenheit = 9 / 5 * Celsius + 32 ].
Function Real convertTempC(Real celsius)
b) Define a function called convertTempF(). The function should have a parameter that will be used to accept temperatures in degrees Fahrenheit. The function should return the converted temperature in degrees Celsius. The formula is [ Celsius = 5 / 9 * Fahrenheit
Explanation / Answer
#include<stdio.h>
int convertTempC(int c);
int convertTempF(int f);
//answer for part c
main()
{
int temperature,degC,degF;
char degree;
printf("enter temperature ");
scanf("%d",&temperature);
printf("enter degree c|C|f|F ");
scanf("%c",degree);
//answer for part d
if(degree=='c'||degree=='C')
{
degF=convertTempF(temperature);
printf("temperature in celsius %d is %d fahrenheit ",temperature,degF);
}
else
if(degree=='f'||degree=='F')
{
degC=convertTempC(temperature);
printf("temperature in celsius %d is %d fahrenheit ",temperature,degC);
}
else
printf("invalid input ");
}
// answer for part a
int convertTempC(int c)
{
return ((9/5)*c)+32;
}
//answet for part b
int convertTempF(int f)
{
return ((5/9)*f)-32;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.