i tried to calculate the following formula but it is not taking the -ve sign due to which it is giving the wrong value.
Code:
#include <stdio.h>
#include <string.h>
#include <math.h>
void read();
int Time, RH, retv;
float DewPointC;
float DryTempC;
float val, val1;
float VPD,vapourp, setvapp;
char line[256];
FILE *in;
int main()
{
in = fopen("KBIS_2005.txt", "r");
read();
return 0;
}
void read()
{
int i;
char store, store1;
char * set, * set1;
printf("VDP\n");
for(i = 0; i<=240; i++)
{
fgets(line,256,in);
retv=sscanf(line,"%d %f %f %d\n",&Time,&DewPointC,&DryTempC,&RH);
if (!retv) continue;
val = ((7.5 * DewPointC) / (237.7 + DewPointC));
vapourp = pow(611,(7.5 * DewPointC) / (237.7 + DewPointC));
printf("the vapourp is :%f",vapourp);
setvapp = pow(611, (7.5 * DryTempC)/(237.7 + DryTempC));
printf("the setvapp is :%f",setvapp);
VPD = setvapp - vapourp;
printf("VPD IS %f",VPD);
if(VPD < 0.5)
{
printf("value is %d\n",1);
}
else
{
printf("value is %d ",0);
}
}
}
here in this code, the value must be 0 for the first reading but since it is giving in -ve sign, it is giving 1 as a result which is wrong. i know the formula is correct. how to make sure that it reads the -ve sign too.