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

Question (C programming) Write a program that will convert from Celsius to Fahre

ID: 2246402 • Letter: Q

Question

Question (C programming)

Write a program that will convert from Celsius to Fahrenheit and vice versa. The program should also print the table as requested by the user. Create at least two (2) functions, celsiusToFahrenheit() and fahrenheitToCelsius() to do the conversion. You can also create a menu to simplify the selection process. (Fahrenheit = 9/5 Celsius + 32)

Sample of program output is as shown below:

Welcome to Temperature Converter 1. Celsius to Fahrenheit 2. Fahrenheit to Celcius 3. Print Converter Table 4. End Selection : 1 Please enter value in Celsius: 0 0 degree Celsius is equivalent to 32 degree Fahrenheit 1. Celsius to Fahrenheit 2. Fahrenheit to Celcius 3. Print Converter Table 4. End Selection: 3 Please choose 1 . Celsius or 2. Fahrenheit: 1 Enter your starting value in Celsius: 2 Enter your end value in Celsius: 7 Printing Chart.. Celsius Fahrenheit 35.60 37.40 39.20 41.00 42.80 44.60 1. Celsius to Fahrenheit 2. Fahrenheit to Celcius 3. Print Converter Table 4. End Selection: 4 Press any key to continue

Explanation / Answer

#include<stdio.h>

#include<conio.h>

void celsius_to_fahrenheit(int);

void fahreheit_to_celsius(int);

void main()

{

int ch,c f;

while(1)

{

printf("1.celsius to fahrenheir 2.fahrenheit to celsius 3.print conver table 4.end ");

printf("selection");

scanf("%d",&ch);

switch(ch)

{

case 1: printf("please enter value in celsius");

scanf("%d",&c);

celsius_to_fahrenheit(c);

break;

case 2: printf("please enter value in fahrenheit");

scanf("%d",&f);

fahrenheit_to_celsius(f);

break;

case 3: printf("please choose 1.celsius 2.fahrenheit");

int op,s,e;

scanf("%d",&op);

if(op==1)

{

printf("enter your starting value in celsius");

scanf("%d",&s);

printf("enter your ending value in celsius");

scanf("%d",&e);

printf("celsius fahrenheit");

for(int i=s;i<=e;i++)

{

printf("%d %f",i,celsius_to_fahrenheit(i));

}

}

else

{   

printf("enter your starting value in fahrenheit");

scanf("%d",&s);

printf("enter your ending value in fahrenheit");

scanf("%d",&e);

printf("fahrenheit celsius");

for(int i=s;i<=e;i++)

{

printf("%d %f",i,fahrenheit_to_celsius(i));

}

}

break;

case 4: exit();

}

}

celsius_to_fahrenheit(int c)

{

float f;

f=c*(9/5)+32;

printf("%f",f);

}

fahrenheit_to_celsius(int f)

{

float c;

c=(f-32)*(5/9);

printf("%f",c);

}