C program through mysql pull
I have this code to find the mean and standard deviation of some input values. But it's a static program. I want to pull this through a MySQL database and use it. Can you help me out?
int main[] [ /* 2-dimensional array is used to store the height,lenght and the width attributes of the nose. indian array represents the indian data and the china array represents the chinese data */ /* Mean variable represents the mean values. The subscripts are used to identify indian and chinese attributes */ float indian[MAX][3],china[MAX] [3],mean_i开发者_JAVA百科h=0,mean_il=0,mean_iw=0,mean_ch=0,mean_cl=0,mean_cw=0; /* Following float variables store the standard deviation values */ float sd_ih=0,sd_il=0,sd_iw=0,sd_ch=0,sd_cl=0,sd_cw=0; int i,j; float test_h,test_l,test_w;
/* POPULATING THE INDIAN DATABASE */
indian[i][j]=random[]/DIV;
/POPULATING THE CHINESE DATABASE/
china[i][j]=random[]/DIS;
Finding the MEAN of the Indian and the Chinese Data
mean_ih+=indian[i][0]; mean_il+=indian[i][1]; mean_iw+=indian[i][2]; mean_ch+=china[i][0]; mean_cl+=china[i][1]; mean_cw+=china[i][2]; mean_ih=mean_ih/MAX; mean_il=mean_il/MAX; mean_iw=mean_iw/MAX; mean_ch=mean_ch/MAX; mean_cl=mean_cl/MAX; mean_cw=mean_cw/MAX;
To find the Standard Deviation of the entries
sd_ih+=pow[[indian[i][0]-mean_ih],2]; sd_il+=pow[[indian[i][1]-mean_il],2]; sd_iw+=pow[[indian[i][2]-mean_iw],2]; sd_ch+=pow[[china[i][0]-mean_ch],2]; sd_cl+=pow[[china[i][1]-mean_cl],2]; sd_cw+=pow[[china[i][2]-mean_cw],2]; sd_ih=sqrt[sd_ih/MAX]; sd_il=sqrt[sd_il/MAX]; sd_iw=sqrt[sd_iw/MAX]; sd_ch=sqrt[sd_ch/MAX]; sd_cl=sqrt[sd_cl/MAX]; sd_cw=sqrt[sd_cw/MAX];
Prompting the user to enter data to verify
printf [" \n ============================================================\n"]; printf[" \n Enter the Height \n"]; scanf[" %f",&test_h]; printf [" \n ============================================================\n"]; printf[" \n Enter the length \n"]; scanf["%f",&test_l]; printf [" \n ============================================================\n"]; printf[" \n Enter the width \n "]; scanf ["%f",&test_w]; printf [" \n ============================================================\n"]; if [[abs[mean_ih-test_h]You will need to look at the mySQL C API documentation here for how to connect to a MySQL database through a C program.
For a tutorial, you can also take a look at this.
精彩评论