Problem 2 (35 points): Van Der Waals equation As the temperature and the volume
ID: 3889944 • Letter: P
Question
Problem 2 (35 points): 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) V is 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 (L2-atm/mol2 0.0341 0.244 1.36 6.49 3.59 Gas Type b(L/mol 0.0237 0.0266 0.0318 0.0562 0.0427 as Helium, He Hydrogen, H2 Oxygen, O2 Chlorine, Cl2 Carbon dioxide, CO2 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); See sample code execution on the next pageExplanation / Answer
#include<stdio.h>
void print_list(void){
printf("%15s%15s%15s%15ds ", "GasType","Gas","a(L^2-atm/mol^2)", "b(L/mol)");
printf("%15s%15s%15s%15ds ", "1","Heleium,He","0.0341", "0.0237");
printf("%15s%15s%15s%15ds ", "2","Hydrogen,H2","0.244", "0.0266");
printf("%15s%15s%15s%15ds ", "3","Oxygen,O2","1.36", "0.0318");
printf("%15s%15s%15s%15ds ", "4","Chlorine,Cl2","6.49", "0.0562");
printf("%15s%15s%15s%15ds ", "5","Carbon dioxide,CO2","3.59", "0.0427");
}
double presure_cal(int gas_type, double T, double V, double n){
double a[5];
double b[5];
double value;
a[0] = 0.0341;
a[1] = 0.244;
a[2] = 1.36;
a[3] = 6.49;
a[4] = 3.59;
b[0] = 0.0237;
b[1] = 0.0266;
b[2] = 0.0318;
b[3] = 0.0562;
b[4] = 0.0427;
value = (0.08206 * T)/((V/n)-b[gas_type-1]) - a[gas_type-1]/((V/n)*(V/n));
return value;
}
int main(){
char c;
double a[5];
double b[5];
int n;
double qty;
double temp;
double ivol;
double fvol;
double incr;
do {
printf("%-30s %-30s ","Number","Gas Type");
printf("%-30s %-30s ","1","Helium");
printf("%-30s %-30s ","2","Hydrogen");
printf("%-30s %-30s ","3","Oxygen");
printf("%-30s %-30s ","4","Chlorine");
printf("%-30s %-30s ","5","Carbon dioxide");
do {
printf("Enter Gas number(1,2,3,5 or 5)>>");
scanf("%d",&n);
} while (n <1 || n >5);
printf("Enter Quantity of gas (in moles)>>");
scanf("%lf",&qty);
printf("Enter temperature (in Kelvin)>>");
scanf("%lf",&temp);
printf("Enter initial volume (in liters)>>");
scanf("%lf",&ivol);
printf("Enter final volume (in liters)>>");
scanf("%lf",&fvol);
printf("Enter volume increment(in liters)>>");
scanf("%lf",&incr);
c = getchar();
printf("%-25s %-25s ","Volume(liters)","Presure(atm)");
while (ivol <= fvol+incr){
printf("%-25lf %-25lf ",ivol,presure_cal(n,temp,ivol,qty));
ivol = ivol + incr;
}
printf("Do you want to continue(y or n)?");
c= getchar();
} while (c != 'n');
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.