I am working on a lab problem. It is: Write a program that calculates the speed of sound (a) in air of a given temperature T (in Fahrenheit). The formula to compute the speed in feet/second:
a = 1086 * sqrt ((5T+297)/247)
Be sure your program does not lose the fractional part of the quotient in the formula shown. As part of your solution, write and call a function that displays instructions to the program user.
I know how to do everything else but keep the fractional part. Below is my program. If anyone could help me out with this I'd really appreciate it. In another problem from this lab we used the scale function to round a number so I'm not sure if we might need to use this function again?
Code:
#include <stdio.h>
#include <math.h>
int main (void)
{
float sound, temperature;
printf("Enter a temperature T in fahrenheit: ");
scanf("%f", &temperature);
sound = 1086 * (sqrt ((5 * temperature + 297) / 247));
printf("When the temperature is %f F, the speed of sound in the air is %f\n", temperature, sound);
return 0;
}