Write a program in C language that calculates
the speed of sound (a) in air of a given temperature
T(˚F). The formula to compute the speed in
ft/sec is:
Use separate functions to:
Compile, run and test your program.
#include <stdio.h> #include <math.h> void print_header_description() { printf("This program asks the user to enter current temperature\n"); printf("Then the program calculates and displays the speed of sound in air based on the given temperature\n\n"); } double read_temperature() { double temp; printf("Enter temperature: "); scanf("%lf", &temp); return temp; } double find_speed_of_sound(double t) { return 1086 * sqrt((5*t + 297) / 247); } void print_speed_of_sound(double t) { double s = find_speed_of_sound(t); printf("Temperature is %.1f\n", t); printf("Speed of sound in air is %.1f\n", s); } int main() { print_header_description(); double t = read_temperature(); print_speed_of_sound(t); return 0; }
Get Answers For Free
Most questions answered within 1 hours.