Answer to Question #330378 in C for Habib

Question #330378

Implement the following functions. The functions return a real number:


(a) Function Celsius returns the Celsius equivalent of a Fahrenheit temperature ((32°F − 32) ×


5/9 = 0°C).


(b) Function Fahrenheit returns the Fahrenheit equivalent of a Celsius temperature.


((0°C × 9/5) + 32 = 32°F)


In main call both functions and ask user to input value of temperature and print its equivalent.

1
Expert's answer
2022-04-19T03:08:22-0400
#include <stdio.h>


int Celsius(int F) {
    int C = (F -32) * 5 / 9.0 + 0.5;
    return C;
}


int Fahrenheit(int C) {
    int F = (C * 9 / 5.) + 32.5;
    return F;
}


int main() {
    int F, C;


    printf("Enter temperature in Farenheit: ");
    scanf("%d", &F);
    C = Celsius(F);
    printf("%dF =  %dC\n", F, C);


    printf("Enter temperature in Celsius: ");
    scanf("%d", &C);
    F = Fahrenheit(C);
    printf("%dC =  %dF\n", C, F);


    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS