Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The density of the gas in a weather balloon determines the height at which it wi

ID: 3632709 • Letter: T

Question

The density of the gas in a weather balloon determines the height at which it will stop rising. Your task is to calculate the gas density for a weather balloon at a given temperature, pressure, and volume.

Program specifics:
Write a C++ program that does the following:

o Reads from the keyboard the temperature in Kelvin (T), the pressure in atmospheres (P), and the volume in liters (V) of a weather balloon filled with helium.

o Computes the moles of helium contained within the balloon, the grams of helium within the balloon, and the density of the gas within the balloon.

o Prints to the screen the entered values of T, P and V, and the results of the calculations. [Make the output as neat as possible, with appropriate labels (include units for all numbers!). You may use functions from <iomanip> lib.]

*• The mass of the gas = n*MW, where MW is the molecular weight of helium (4 gm/mole)
• The density of the gas = mass/volume (gm/liter)

Explanation / Answer

#include <stdio.h>
#include <stdlib.h>
int main()
{
    float T,V,P;
    float R,n,mW, density, mass;
    printf(" Enter Pressure(P), Volume(V) and Temparature(T in kelvin) : ");
    scanf("%f%f%f", &P, &V, &T);
  
    //Molecular weight of helium
    mW = 4.0;//gm/mole
     
    //Ideal gas constant
    R = 8.314;
  
    //Calculating number moles in given volume
    n = (P*V)/(R*T); //Moles  
    mass = n * mW; //gm  
    density = mass/V; //gm/liter
   
    printf(" Pressure (P) = %f atmospheres ",P);
    printf(" Volume (V) = %f liters ",V);
    printf(" Temparature (T) = %f Kelvin ",P);
  
    printf(" Mass = %f gm ",mass);
    printf(" Density = %f gm/liter ",mass);
    getch();
    return 0;
}