Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loopie loo

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Can anyone tell me whot on earth I have done wrong
the program compiles ok but I'm not getting the result I want, either there is something wrong with my loops , math or logic or even all 3
This is part of a program I am coding - everything elseis fine, ok here it is

#include <stdio.h>
#include <math.h>
#include <string.h>

void main()
{
int'
sum=0,
average=0,
throws=10,
score[10],
i, j, k,
total=0;
double standarddev;
char message[11][10];

for( i= 0; i<throws; i++ )
{
printf(&quot;Enter score > &quot;);
scanf(&quot;%d&quot;,&amp;score );
total+=score;
}
average = total/throws;

for(j=0;j<throws;j++ )
{
sum+= (score[j] - average) * (score[j] - average);
}
standarddev = sqrt(sum / (throws -1));

for(i=0; i<throws;i++ )
{
for(j=0; j < throws; j++)
{
if(score[j] >= average + 1.5 * standarddev)
strcpy(message[j],&quot;excellent&quot;);

if(score[j] >= average + 0.5 * standarddev)
strcpy(message[j],&quot;Good&quot;);

if(score[j] >= average + 0.5 * standarddev)
strcpy(message[j],&quot;Fair&quot;);

if(score[j] >= average + 1.5 * standarddev)
strcpy(message[j],&quot;Poor&quot;);

if(score[j] < average + 1.5 * standarddev)
strcpy(message[j],&quot;Very poor&quot;);
}

}
printf(&quot;\n\n&quot;);
message[j] == '\0';

for(k=0; k< throws; k ++)
{
printf(&quot;\n%d\t%s&quot;,k+1, message[k]);
}
}


I'm working on the algo
i =0
while( i < throws)do
sum = sum + (score - average)squared
i=i+i
end while
standarddev = square rout of sum / (throws -1)



Here are the messages for each throw

Excellent if(score[j] >= average + 1.5 * standarddev)

Good if(score[j] >= average + 0.5 * standarddev)

Fair if(score[j] >= average + 0.5 * standarddev)

Poor if(score[j] >= average + 1.5 * standarddev)

very poor if(score[j] < average + 1.5 * standarddev)

perhaps after reading that you might think itd time for me to pack my bags and take up fishing or something,but I would be grateful for any help THanks

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top