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

Van Der Waals equation As the temperature and the volume of the gas changes, the

ID: 3889906 • Letter: V

Question

Van Der Waals equation As the temperature and the volume of the gas changes, the gas pressure changes. The Van Der Waals equation given below is often used for to find pressure of any given gas type R T 2 where P is the pressure (atm) Vis the volume in liters (L) R is gas constant, R = 0.08206 L-atm/mol-K T is the absolute temperature in Kelvin (K) n is the quantity of gas (in mols) a and b depend on the type of gas. Some values are given in Table 1 below a (L'-atm/mol 0.0341 0.244 1.36 6.49 3.59 b(L/mo 0.0237 0.0266 0.0318 0.0562 0.0427 Gas Type Gas Helium, He Hydrogen, H2 Oxygen, O2 Chlorine, Cl Carbon dioxide, CO 4 Implement an interactive C program to let the user enter required information and display, in tabular format, values of volume (Liter (L)) and Pressure (atm) at a given temperature. See sample code execution Your C program should include at least the following user defined functions: print list function is to display the information given in Table 1 above void print_list(void); pressure_cal function returns the value gas pressure given all input values shown below gas type value is between 1 and 5 -to be used to choose correct values of a and b double pressure_cal(int gas_type, double T, double V, double n);

Explanation / Answer

Hi Let me know if you need more information:-

======================================

#include <stdio.h>

void print_list(void);
double pressure_cal(int gas_type, double T, double V, double n);

float dependends[5][5] = { { 0.0341, 0.0237 }, { 0.0341, 0.0237 }, { 0.0341,
       0.0237 }, { 0.0341, 0.0237 }, { 0.0341, 0.0237 } };

void print_list(void) {
   for (int i = 0; i < 5; i++) {
       printf("%d %f %f", i, dependends[i][0], dependends[i][1]);
       printf(" ");
   }
}
/*
* (RT/((V/n) -b)) - (a/((V*V)/(n*n)))
*/
float R = 0.08206;
double pressure_cal(int gas_type, double T, double V, double n) {
   double a = dependends[gas_type][0];
   double b = dependends[gas_type][1];
   return (R * T / ((V / n) - b)) - (a / ((V * V) / (n * n)));
}
int main() {

   //print_list();

   int gas_type;
   double T;
   double V;
   double FV;
   double n;
   double increment;
   char choice = { 0 };
   while (1) {

       printf("1 Helium ");
       printf("2 Hydrogen ");
       printf("3 Oxygen ");
       printf("4 Chlorine ");
       printf("5 Carbon dioxide ");
       fflush(stdout);
       while (1) {

           printf("Enter Gas number>>");
           fflush(stdout);
           scanf("%d", &gas_type);
           if (gas_type < 1 || gas_type > 6) {
               continue;
           }
           printf("Enter quantity of gas(in moles)>>");
           fflush(stdout);
           scanf("%lf", &n);
           fflush(stdout);
           printf("Enter temperature of gas(in Kelvin)>>");
           fflush(stdout);
           scanf("%lf", &T);
           fflush(stdout);
           printf("Enter initial volume of gas(in liters)>>");
           fflush(stdout);
           scanf("%lf", &V);
           fflush(stdout);
           printf("Enter final volume of gas(in liters)>>");
           fflush(stdout);
           scanf("%lf", &FV);
           fflush(stdout);
           printf("Enter volume increment of gas(in liters)>>");
           fflush(stdout);
           scanf("%lf", &increment);
           printf(" Volume (liters) Pressures(atm) ");
           fflush(stdout);
           double final = FV;
           for (double i = V; i <= final + 0.0000000001; i += increment) {
               printf("%lf %lf ", i, pressure_cal(gas_type, T, i, n));
               fflush(stdout);
           }
           break;

       }
       printf("Do you want to continue (y or n)?");
       fflush(stdout);
       scanf(" %c", &choice);
       if (choice == 'n') {
           return 0;
       }

   }
   fflush(stdout);

   return 0;
}


===========

OUTPUT:-

===============

1   Helium
2   Hydrogen
3   Oxygen
4   Chlorine
5   Carbon dioxide
Enter Gas number>>10
Enter Gas number>>8
Enter Gas number>>5
Enter quantity of gas(in moles)>>0.02
Enter temperature of gas(in Kelvin)>>300
Enter initial volume of gas(in liters)>>0.4
Enter final volume of gas(in liters)>>0.6
Enter volume increment of gas(in liters)>>0.05
Volume (liters)        Pressures(atm)

0.400000           1.230695
0.450000           1.093971
0.500000           0.984589
0.550000           0.895092
0.600000           0.820509
Do you want to continue (y or n)?n

=====

====================

Thanks