Write a program that calculates and displays the pressure of a perfect gas at a constant temperature in a gravitational field: \(P(z)=P_0 \times \exp{-\frac{Mgz}{RT}}\), with \(P_0=10^5 hP\), \(M=29 g.mol^{-1}\), \(g=9.8 m.s^{-1}\), \(R=8.32 J.K^{-1}.mol^{-1}\), \(T=300k\), and \(z=4000 m\). These numerical values will have to be given in the program, and not requested to the user.
Difficulty level

This exercise is mostly suitable for students
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
double P0=1e5, M=29e-3, g=9.8, R=8.32, T=300, z=4e3;
printf("P(z=4000 m)=%lg\n",P0*exp(-M*g*z/R/T));
getch();
}
Back to the list of exercises
Looking for a more challenging exercise, try this one !!
