The task is to write a program that will take an Celsius value and convert and d
ID: 3627196 • Letter: T
Question
The task is to write a program that will take an Celsius value and convert and display a Fahrenheit value. Then prompt a Fahrenheit value and convert and display a Celsius value. It must be written using functions. I am given the fact that F = 32+ (C * 1.8)Here is what I have so far, please explain any steps as I am weak in my understanding
of using functions:
#include <stdio.h>
float fehrntConvrt (int cel);
float clcsConvrt (int fahrnht);
int main (void)
{
int cel;
int fahrnht;
int a;
printf("This program takes a Celsius measurement, and converts it into ");
printf("Fahrenheit. It then takes a Fahrenheit measurement and converts it ");
printf("into Celsius. ");
printf("Please enter a Celsius temperature. ");
scanf("%d ", &cel);
printf("Please enter a Fahrenheit temperature. ");
scanf("%d", &fahrnht);
printf("Here is your Celsius measurement in Fahrenheit: %f ", celcsConvrt);
scanf("%d", &a);
return 0;
}
double celcsConvert()
{
celcsConvert = 32 + (int cel * 1.8);
return celcsConvert;
}
Explanation / Answer
#include <stdio.h>
#include<conio.h>
double fehrntConvrt (int cel);
double clcsConvrt(int fahrnht);
int main (void)
{
int cel;
int fahrnht;
printf("This program takes a Celsius measurement, and converts it into ");
printf("Fahrenheit. It then takes a Fahrenheit measurement and converts it ");
printf("into Celsius. ");
printf("Please enter a Celsius temperature. ");
scanf_s("%d", &cel);
printf("Please enter a Fahrenheit temperature. ");
scanf_s("%d", &fahrnht);
printf("Here is your Celsius measurement in Fahrenheit: %f ", fehrntConvrt(cel));
printf("Here is your Fahrenheit measurement in Celsius: %f ", clcsConvrt(fahrnht));
getch();
return 0;
}
double clcsConvrt(int fahrnht)
{
double cels;
cels = (fahrnht - 32 )* 1.8;
return cels;
}
double fehrntConvrt(int cel)
{
double fehr;
fehr = 32 + ( cel * 1.8);
return fehr;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.