I need some C programming help. I am using Visual Studios. Here are the instruct
ID: 3118942 • Letter: I
Question
I need some C programming help. I am using Visual Studios. Here are the instructions for the program:
Write a program that converts a user entered temperature in Fahrenheit to Celsius incorporating three modules and functions named as identified below. The user entered Fahrenheit temperature is to be passed as an argument to the function named convert( ) in the module "conversion.c". The calculated Celsius value is to be return by the function and the result displayed to the user in the function main( ) :
convert_driver.c - contains the function main( ) and the user interface
conversion.h - contains the prototype for a function named convert( )
convertsion.c - contains the function definition for convert( )
I created a console application. From there, I wen to "Source File" and created "conver_driver.c", "conversion.h", and "convertsion.c". I thought I was doing it right, but now I'm not so sure. This is what I have so far:
/*conversion.h*/
#include <stdio.h>
double convert(double);
------------------------------------------------
/*convert_driver.c*/
#include <stdio.h>
#include <stdlib.h>
#include "conversion.h"
double F, C;
int main()
{
printf("Enter the Fahrenheit value:");
scanf("%lf ", F);
C = convert(F);
printf("Here is the Celsius value: %lf", C);
return 0;
}
------------------------------------------------
/*convertsion.c*/
#include<stdio.h>
double convert(double F)
{
double C;
C = (5 / 9)* (F - 32);
return (C);
}
Thank you for the help!
Explanation / Answer
int main()
{
float temp_f, temp_c;
printf("Temperature in Fahrenheit: ");
scanf("%f",&temp_f);
temp_c = convert(temp_f);
printf("%.1fF is %.1fCn",temp_f,temp_c);
return(0);
}
float convert(float f)
{
float t;
t = (f - 32) / 1.8;
return(t);
}