Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that performs conversion between temperatures. You will first re

ID: 3539626 • Letter: W

Question

Write a program that performs conversion between temperatures. You will first read a character for the type of the temperature and a floating point value for the temperature from the user. If the character is %u2018F%u2019 or %u2018f%u2019, it means that the degrees is Fahrenheit. If the character is %u2018C%u2019 or %u2018c%u2019, it means that the degrees is Celsius. If the given temperature is of degree Celsius, convert it to degree Fahrenheit, else if the given temperature is of degree Fahrenheit, convert it to degree Celsius. If the entered character is different than %u2018F%u2019, %u2018f%u2019, %u2018C%u2019, or %u2018c%u2019, display the temperature with no conversion. The formulas for the conversions are as follows:


Tc = (5/9) * (Tf-32)

Tf = (9/5) * Tc+32


Where Tc=temperature in degrees Celsius, Tf=temprarure in degrees Fahrenheit


Note: The temperature can be floating point value. You must do the calculation using floating point values. However you must only display the integer part of the result.


Example:


Input Output

F 98.6 37

F 66 18

F 20.4 -6

C 56.2 133

K 12.57 12

Explanation / Answer

#include<stdio.h>

#include <math.h>

int main()

{

float data;

char input;

printf("First enter c for celcius and f for foharnhite ");

scanf("%c",&input);

if (input=='c')

{

scanf("%f",&data);

float dataout = (9/5) * data+32;

printf("%f C = %f F",data,dataout);

}

else if (input=='f')

{

scanf("%f ",&data);

float dataout;

dataout = (5/9) * (data-32);

printf("%f C = %f F",data,dataout);

}

else

printf("Incorrect input");

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote