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("Enter score > "
scanf("%d",&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("\n%d \t %d \texcellent",j+1,score[j]);
if(score[j] >= average + 0.5 * standarddev)
printf("\n %d \t %d \tGood",j+1,score[j]);
if(score[j] >= average - 0.5 * standarddev)
printf("\n%d \t%d \tFair",j+1,score[j]);
if(score[j] >= average - 1.5 * standarddev)
printf("\n%d \t %d \tPoor",j+1,score[j]);
if(score[j] < average - 1.5 * standarddev)
printf("\n%d \t %d \tVery Poor",j+1,score[j]);
}
}
///////// check variables //////////
//printf("\n\n"
//for(k=0; k< throws; k ++)
// {
// printf("\n%d\t%d\t%s",k+1,score[k], message[k]);
// }
// printf("\nsum = %d",sum);
// printf("\tstdv = %d",(int)standarddev);
//printf("\taverage = %d",average);
}
//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("Enter score > "
scanf("%d",&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("\n%d \t %d \texcellent",j+1,score[j]);
if(score[j] >= average + 0.5 * standarddev)
printf("\n %d \t %d \tGood",j+1,score[j]);
if(score[j] >= average - 0.5 * standarddev)
printf("\n%d \t%d \tFair",j+1,score[j]);
if(score[j] >= average - 1.5 * standarddev)
printf("\n%d \t %d \tPoor",j+1,score[j]);
if(score[j] < average - 1.5 * standarddev)
printf("\n%d \t %d \tVery Poor",j+1,score[j]);
}
}
///////// check variables //////////
//printf("\n\n"
//for(k=0; k< throws; k ++)
// {
// printf("\n%d\t%d\t%s",k+1,score[k], message[k]);
// }
// printf("\nsum = %d",sum);
// printf("\tstdv = %d",(int)standarddev);
//printf("\taverage = %d",average);
}