Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Dasproc C - 2019
- William Handi Wijaya
- 0087
- Menampilkan tabel perbandingan volume dan tekanan unsur
- */
- #include <stdio.h>
- #define a 3.592 //konstanta a van der walls
- #define b 0.0427 //konstanta b van der walls
- #define R 0.08206 //konstanta R
- void print_table(double, double);
- int main() {
- //variable declaraations
- double volume_initial, // input - volume awal
- volume_final, // input - volume akhir
- volume_increment, // input - pertambahan volume untuk tabel
- kelvin_temp, // input - temperatur dalam kelvin
- moles, // input - besar mol unsur (co2)
- pressure; // tekanan
- //program intro
- printf("\nPlease enter at the prompts the number of moles of carbon dioxide, the absolute temperature, the initial volume in milliliters, the final volume, and the increment volume between lines of the table.");
- //get values
- printf("\nQuantity of carbon dioxide (moles)>");
- scanf("%lf", &moles);
- printf("\nTemperature (kelvin)>");
- scanf("%lf", &kelvin_temp);
- printf("\nInitial volume (milliliters)>");
- scanf("%lf", &volume_initial);
- printf("\nFinal volume (milliliters)>");
- scanf("%lf", &volume_final);
- printf("\nVolume increment (milliliters)>");
- scanf("%lf", &volume_increment);
- //displays the result
- printf("\nVolume (ml) %5c Pressure (atm)",' ');
- //loop for each case
- while(volume_initial <= volume_final)
- {
- pressure = ((moles*R *kelvin_temp) / (volume_initial/1000 - (b * moles))) - ((a * moles * moles) / volume_initial/1000 * volume_initial/1000);
- print_table(volume_initial, pressure);
- volume_initial += volume_increment;
- }
- printf("\n");
- }
- //printing functions
- void print_table(double volume, double pressure)
- {
- printf("\n%3c%.2f %10c %.4f",' ', volume, ' ', pressure);
- }
Advertisement
Add Comment
Please, Sign In to add comment