Sound travels through air as a result of collisions between the molecules in the
ID: 3885196 • Letter: S
Question
Sound travels through air as a result of collisions between the molecules in the air. The temperature of the air affects the speed of the molecules, which in turn affects the speed of sound. The velocity of sound in dry air can be approximated by the formula: velocity almostequalto 331.3 + 0.61 times T_c where T_c is the temperature of the air in degrees Celsius and the velocity is in meters/second. Write a program that allows the user to input a starting and an ending temperature. Within this temperature range, the program should output the temperature and the corresponding velocity in 1 degree increments. For example, if the user entered 0 as the start temperature and 2 as the end temperature, then the program should output At 0 degrees Celsius the velocity of sound is 331.3 m/s At 1 degrees Celsius the velocity of sound is 331.9 m/s At 2 degrees Celsius the velocity of sound is 332.5 m/sExplanation / Answer
#include <iostream>
using namespace std;
int main()
{
int start, end;
double temp;
cout << "Enter the starting temparature: ";
cin >> start;
cout << "Enter the ending temparature: ";
cin >> end;
for(int i=start; i<=end;i++) {
temp = 331.3 + i * 0.61;
cout<<"At "<<i<<" degrees celcius the velocity of the sound is "<<temp<<" m/s"<<endl;
}
return 0;
}
Output:
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.