Hi,
Anyone here can advise me correction of my c programming?
It doesn't seem to be working.
#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;
for (i=0; 1<4;i++) ftotal + = f;
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);
}
What should i add on so that user can enter the four weights from the keyboard. The program should print an error message is the weights are out of range?
shermaine 0 Light Poster
shermaine 0 Light Poster
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
shermaine 0 Light Poster
shermaine 0 Light Poster
shermaine 0 Light Poster
andor 25 Posting Whiz in Training
bumsfeld 413 Nearly a Posting Virtuoso
shermaine 0 Light Poster
shermaine 0 Light Poster
shermaine 0 Light Poster
shermaine 0 Light Poster
shermaine 0 Light Poster
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
shermaine 0 Light Poster
WolfPack 491 Posting Virtuoso Team Colleague
shermaine 0 Light Poster
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.