943,609 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Marked Solved
  • Views: 3818
  • C RSS
You are currently viewing page 2 of this multi-page discussion thread; Jump to the first page
May 3rd, 2007
0

Re: Averaging and grading program in C

so why do u divede by 5 not 3
Reputation Points: 10
Solved Threads: 0
Newbie Poster
cyberman111 is offline Offline
24 posts
since May 2007
May 3rd, 2007
0

Re: Averaging and grading program in C

also it is givin me the wrong output

i need to list the avg of all the students entered with a *** next to the ones with 95% or higher
Reputation Points: 10
Solved Threads: 0
Newbie Poster
cyberman111 is offline Offline
24 posts
since May 2007
May 3rd, 2007
0

Re: Averaging and grading program in C

Because there are five students. The first average taken inside of the loop is the average of a single student's three grades. The second average taken outside of the loop is the average of all five student's averages.
Administrator
Reputation Points: 6442
Solved Threads: 1393
Bad Cop
Narue is offline Offline
11,807 posts
since Sep 2004
May 3rd, 2007
0

Re: Averaging and grading program in C

>also it is givin me the wrong output
What's wrong about it?

>i need to list the avg of all the students entered with a *** next to the ones with 95% or higher
We haven't gotten to that part yet. You don't write everything in one swell foop, you write a little and test a little until all of the features are added and working properly.
Administrator
Reputation Points: 6442
Solved Threads: 1393
Bad Cop
Narue is offline Offline
11,807 posts
since Sep 2004
May 3rd, 2007
0

Re: Averaging and grading program in C

/*for (x=0; x<2; x++)
{
if (st[x].id == 0)
break;
printf("\n %ld ", st[x].id);
printf("\t %s ", st[x].name);
printf("\t %.1f ", st[x].assignment); //print average instead and *** when >95
} */
double sum = 0;
for (x=0; x<2; x++)
{
double avg = ( st[x].assignment + st[x].quiz1 + st[x].quiz2 ) / 3;
if (st[x].id == 0)
break;
printf("\n %ld ", st[x].id);
printf("\t %s ", st[x].name);
printf("\t %.1f ", avg );
sum += avg;
}
printf ( "\nTotal average: %f\n", sum / 3 );
Reputation Points: 10
Solved Threads: 0
Newbie Poster
cyberman111 is offline Offline
24 posts
since May 2007
May 3rd, 2007
0

Re: Averaging and grading program in C

hey it worked narue yo the man
i figur wat was wrong i had the tot # of student to 25 so i changed it all to 2 and it worked
now how do i place ** next to the ones with 95 %
Reputation Points: 10
Solved Threads: 0
Newbie Poster
cyberman111 is offline Offline
24 posts
since May 2007
May 3rd, 2007
0

Re: Averaging and grading program in C

i relized it was just a simple mistake at teh begging of the code i had set it to 25 studetns but by the time i got to the bottom i just put in a random number of students

now i am done with that how do I add ***
would it be another if statement
such as

else if
Reputation Points: 10
Solved Threads: 0
Newbie Poster
cyberman111 is offline Offline
24 posts
since May 2007
May 3rd, 2007
0

Re: Averaging and grading program in C

I DID ALL BYMYSELF LOL JK NARUE THANK YOU VERY MUCH YOUR GUIDENCE HELPED ALOT
LOOK AT THE OUTCOME
double sum = 0;
for (x=0; x<2; x++)
{
double avg = ( st[x].assignment + st[x].quiz1 + st[x].quiz2 ) / 3;
if (st[x].id == 0)
break;
printf("\n %ld ", st[x].id);
printf("\t %s ", st[x].name);
printf("\t %.1f ", avg );
if (avg > 95)
printf("*****");

sum += avg;
}
printf ( "\nTotal average: %f\n", sum / 3 );
}
Reputation Points: 10
Solved Threads: 0
Newbie Poster
cyberman111 is offline Offline
24 posts
since May 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: Class help needed
Next Thread in C Forum Timeline: Initialising Video Modes





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC