-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathex43.c
49 lines (37 loc) · 1.92 KB
/
ex43.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <stdio.h>
#include <stdlib.h>
#include "comphys.h"
#include "comphys.c"
int main(){
int ni;
int i = 0;
int j;
int x;
double y;
//double m;
int xn[79] = {50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,905,910,915,920,925,930,935,940,945,950,955,960,965,970,975,980,985,990,995,1000,1005,1010,1015,1020,1025,1030,1035,1040,1045,1050,1055,1060,1065,1070,1075,1080,1085,1090,1095,1100,1150,1200,1250,1300,1350,1400,1450,1500,1550,1600,1650,1700,1750,1800,1850,1900,1950,2000,2050,2100,2150};
double yn[79] = {32.88, 45.82,53.98,60.07,64.98,69.11,72.70,75.88,78.74,81.34,83.73,85.95,88.02,89.96,91.78,93.51,95.15, 96.71, 96.87, 97.02, 97.17, 97.32, 97.47, 97.62, 97.76,97.91, 98.06, 98.21, 98.35, 98.50, 98.64, 98.78, 98.93, 99.07, 99.21, 99.35, 99.49, 99.63, 99.77, 99.91, 100.05, 100.19, 100.32, 100.46, 100.60, 100.73, 100.87, 101.00, 101.14, 101.27, 101.40, 101.54, 101.67, 101.80, 101.93, 102.06, 102.19, 102.32, 103.59, 104.81, 105.99, 107.14, 108.25, 109.32, 110.36, 111.38, 112.37, 113.33, 114.26, 115.18, 116.07, 116.94, 117.79, 118.63, 119.44, 120.24, 121.02, 121.79, 122.54};
printf("Enter a pressure between 50 and 2150 mbar to return\nthe boiling temperature of water at that pressure.\n > ");
ni = scanf("%d",&x);
while(x > 2150 || x < 50){
printf("Please enter a value between 50 and 2150 mbar\n > ");
ni = scanf("%d",&x);
}
for(j=0;j<=78;j++){
if(x > xn[j] && x < xn[j+1]){
i=j;
break;
}else if(x == xn[j]){
i=j;
printf("BP (Celcius) = %3.2lf\n",yn[i]);
exit(0);
}
}
//m = (yn[i+1] - yn[i])/(xn[i+1] - xn[i]);
y = yn[i] + (yn[i+1] - yn[i])*(x - xn[i])/(xn[i+1] - xn[i]);
printf("BP (Celcius) = %3.2lf\n",y);
//free_dvector(yn,1,79);
//free_ivector(xn,1,79);
//free_dmatrix(z,1,2,1,79);
return(0);
}