Hi,
Can this be done?
#include<stdio.h>
float x[4] = {1.2,2.4,3.6,4.8};
float f[4] = {0.1,0.2,0.3,0.4};
float xave = 0.0;
float ftotal = 0.0;
main()
{
int i;
float weights[4] = {0};
char buf[80];
for(i = 0; i < 4; ++i)
{
printf("Enter weight #%d", i+1);
fgets(buf,sizeof(buf),stdin);
weights[i] = atof(buf);
}
{
int i;
for (i=0; 1<4;i++) ftotal + = f[i];
if(ftotal!=1.0)
{
printf("error\n");
exit();
}
for(i=0;1<4;i++) xave+=f *x;
printf("\nThe weights are %f"&f);
printf("\nThe average is %f\n",xave);
}
But seem to hv compilng errors...can anyone please help me out where should i amend correctly yo make it works?
0001 #include<stdio.h>0002 float x[4] = {1.2,2.4,3.6,4.8};0003 float f[4] = {0.1,0.2,0.3,0.4};0004 float xave = 0.0;0005 float ftotal = 0.0;0006 main()0007 {0008 int i;0009 float weights[4] = {0};0010 char buf[80];0011 for(i = 0; i < 4; ++i)0012 {0013 printf("Enter weight #%d", i+1);0014 fgets(buf,sizeof(buf),stdin);0015 weights[i] = atof(buf);0016 }0017 {0018 int i;0019 for (i=0; 1<4;i++) ftotal + = f[i];
parse error before `=' 
0020 if(ftotal!=1.0)0021 {0022 printf("error\n");0023 exit();
at this point in file0024 }0025 for(i=0;1<4;i++) xave+=f *x;
invalid operands `float[4]' and `float[4]' to binary `operator *'0026 printf("\nThe weights are %f"&f);
invalid operands `const char[20]' and `float[4]' to binary `operator &'0027 printf("\nThe average is %f\n",xave);0028 }0029 0030 0031
parse error at end of input confused by earlier errors, bailing out

Syntax Errors found in /usr/include/stdlib.h: