
Originally Posted by
Salem
Post your latest code.
i got the calculation right but i cant input the name of gas because when i do the code wont work and i have a problem with asking the question (Do you want to continue (Y/n) should i write it inside the for loop or outside it.
Code:
#include<stdio.h>
#define R 8.3145
int main()
{
int Temp;
double Gname, Vol, InitialVol, FinalVol, nmoles, Pressure, volIncremnet;
printf("Enter the name of a gas: \n");
printf("quantity of %lf(moles): ");
scanf(" %lf", &Gname);
printf("Tempreture(Kelvin): ");
scanf("%d", &Temp);
printf("Initial Volume(Milliliters): ");
scanf("%lf", &InitialVol);
printf("Final Volume(Milliliters): ");
scanf("%lf", &FinalVol);
printf("Volume Increment(Milliliters): ");
scanf("%lf", &volIncrement);
printf("\n\n%.3lf moles of at %d Kelvin", Gname, Temp);
printf("\nVolume (ml) pressure (atm)");
for(Vol=InitialVol;Vol<=FinalVol;Vol+=volIncrement)
{
printf("\n%2.0lf", Vol);
Pressure=Gname*R*Temp/Vol;
printf(" %9.4lf", Pressure);
}
return 0;
}