Question: Hi, I'm taking a programming class where I am leanring C. I need help on an assignment which is called Temperature Conversion in C. I

Hi,

I'm taking a programming class where I am leanring C. I need help on an assignment which is called Temperature Conversion in C. I have attached the assignment below. I am trying to work on the if statements but I'm not sure how to write them correctly. Thanks!

Here is what I have so far:

#include

int main (void){ float farhenheit,celsius,kelvin; float num; char cha; printf("Please enter a temperature:"); /* reading in the number plus the one letter so it cant be %f */ scanf("%f %c",&num,&cha);

if(cha=='c'){ return float farhenheit = 9/5(kelvin-273.15)+32; return float kelvin = celsius + 273.15; } if(cha=='f'){ return float celsius = (farhenheit-32)/1.8; return float kelvin=celsius + 273.15; } if(cha=='k'){ return float celsius = (farhenheit-32)/1.8;

/*if the input is celsius then convert it to fahrenheit and kelvin *if its kelvin, convert to celsius and fahrenheit *if its fahrenheit, convert to celsius and kelvin *if input is not the proper value print invalid temp scale and return non-0

Hi, I'm taking a programming class where I am leanring C. I

Assignment 3: Temperature conversion in C Due date: Sunday, 10 September 2017, 11:55 PM Maximum number of files: 1 Type of work: Individual work Assignment Write a program in C that converts temperatures between Fahrenheit, Celsius, and Kelvin. Functional Requirements MUST correctly convert temperatures between scales MUST read input by prompting the user Nonfunctional Requirements MUST compile without warnings and errors MUST print error message "Invalid temperature scale" on invalid input .MUST return O on success MUST return non-O value on failure Sample run $ ./temp Enter input temperature: 18c 18.00 C converts tO: 64.40 F 291.15K The conversion formulas are listed below: Celsius - (Fahrenheit 32)/1.8 Kelvin = Celcius + 273.15 NOTE: The converted temperatures are indented by tabs

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!