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!

loopy getting closer

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I have discovered that part of my problem was to do with strcmpy so I have scrapped that for now but i still have probs getting the correct message (not as many probs though)

//take 20 throws output message for each throw

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

void main()
{
int

sum=0,
average=0,
throws=20,
score[20],
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);
// would this be better:- sum+=pow(score[j] - average,2)

standarddev = sqrt(sum / (throws -1));

for(j=0; j < throws; j++)
{
if(score[j] >= average + 1.5 * standarddev)
printf(&quot;\n%d \t %d \texcellent&quot;,j+1,score[j]);

if(score[j] >= average + 0.5 * standarddev)
printf(&quot;\n %d \t %d \tGood&quot;,j+1,score[j]);

if(score[j] >= average - 0.5 * standarddev)
printf(&quot;\n%d \t%d \tFair&quot;,j+1,score[j]);

if(score[j] >= average - 1.5 * standarddev)
printf(&quot;\n%d \t %d \tPoor&quot;,j+1,score[j]);


if(score[j] < average - 1.5 * standarddev)
printf(&quot;\n%d \t %d \tVery Poor&quot;,j+1,score[j]);
}

}
///////// check variables //////////
//printf(&quot;\n\n&quot;);

//for(k=0; k< throws; k ++)
// {
// printf(&quot;\n%d\t%d\t%s&quot;,k+1,score[k], message[k]);
// }
// printf(&quot;\nsum = %d&quot;,sum);
// printf(&quot;\tstdv = %d&quot;,(int)standarddev);
//printf(&quot;\taverage = %d&quot;,average);
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top