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("Enter score > "
scanf("%d",&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],"excellent"
if(score[j] >= average + 0.5 * standarddev)
strcpy(message[j],"Good"
if(score[j] >= average + 0.5 * standarddev)
strcpy(message[j],"Fair"
if(score[j] >= average + 1.5 * standarddev)
strcpy(message[j],"Poor"
if(score[j] < average + 1.5 * standarddev)
strcpy(message[j],"Very poor"
}
}
printf("\n\n"
message[j] == '\0';
for(k=0; k< throws; k ++)
{
printf("\n%d\t%s",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
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("Enter score > "
scanf("%d",&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],"excellent"
if(score[j] >= average + 0.5 * standarddev)
strcpy(message[j],"Good"
if(score[j] >= average + 0.5 * standarddev)
strcpy(message[j],"Fair"
if(score[j] >= average + 1.5 * standarddev)
strcpy(message[j],"Poor"
if(score[j] < average + 1.5 * standarddev)
strcpy(message[j],"Very poor"
}
}
printf("\n\n"
message[j] == '\0';
for(k=0; k< throws; k ++)
{
printf("\n%d\t%s",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