frain8

Untitled

Nov 19th, 2019
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.74 KB | None | 0 0
  1. /* Dasproc C - 2019
  2. William Handi Wijaya
  3. 0087
  4.  
  5. Menampilkan tabel perbandingan volume dan tekanan unsur
  6. */
  7.  
  8. #include <stdio.h>
  9. #define a 3.592  //konstanta a van der walls
  10. #define b 0.0427 //konstanta b van der walls
  11. #define R 0.08206 //konstanta R
  12.  
  13. void print_table(double, double);
  14. int main() {
  15.     //variable declaraations
  16.     double volume_initial, // input - volume awal
  17.            volume_final, // input - volume akhir
  18.            volume_increment, // input - pertambahan volume untuk tabel
  19.            kelvin_temp, // input - temperatur dalam kelvin
  20.            moles, // input - besar mol unsur (co2)
  21.            pressure; // tekanan
  22.     //program intro
  23.     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.");
  24.     //get values
  25.     printf("\nQuantity of carbon dioxide (moles)>");
  26.     scanf("%lf", &moles);
  27.     printf("\nTemperature (kelvin)>");
  28.     scanf("%lf", &kelvin_temp);
  29.     printf("\nInitial volume (milliliters)>");
  30.     scanf("%lf", &volume_initial);
  31.     printf("\nFinal volume (milliliters)>");
  32.     scanf("%lf", &volume_final);
  33.     printf("\nVolume increment (milliliters)>");
  34.     scanf("%lf", &volume_increment);
  35.     //displays the result
  36.     printf("\nVolume (ml) %5c Pressure (atm)",' ');
  37.    
  38.         //loop for each case
  39.     while(volume_initial <= volume_final)
  40.     {
  41.         pressure = ((moles*R *kelvin_temp) / (volume_initial/1000 - (b * moles))) - ((a * moles * moles) / volume_initial/1000 * volume_initial/1000);
  42.        
  43.         print_table(volume_initial, pressure);
  44.        
  45.         volume_initial += volume_increment;
  46.     }
  47.     printf("\n");
  48. }
  49. //printing functions
  50. void print_table(double volume, double pressure)
  51. {
  52.     printf("\n%3c%.2f %10c %.4f",' ', volume, ' ', pressure);
  53. }
Advertisement
Add Comment
Please, Sign In to add comment