943,551 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 621
  • C RSS
Jan 22nd, 2009
0

can you help me on this problem please?

Expand Post »
i have exams tomorrow and i really really need someones help on my problem. here how it goes:

"we have 100 students info such as surname,name,id and grades for 6 lessons for those students.
the program must:

- can take grades from 1 to 10
- can calculate and find which students have average above 5
- we should give the surname of the student and then show us the max grade of that student
- the program will finish when we type the word "end"

please give me all your help i need this soo much its my exams tomorrow and i really need help.thanks in advance!
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
sotiris25s is offline Offline
4 posts
since Jan 2009
Jan 22nd, 2009
0

Re: can you help me on this problem please?

>please give me all your help i need this soo much its my exams tomorrow and i really need help.thanks in advance!

Sure, tell me the e-mail of your professor at school and I'll ask him to give you a break.
Aia
Reputation Points: 2224
Solved Threads: 218
Nearly a Posting Maven
Aia is offline Offline
2,304 posts
since Dec 2006
Jan 22nd, 2009
0

Re: can you help me on this problem please?

Click to Expand / Collapse  Quote originally posted by Aia ...
>Sure, tell me the e-mail of your professor at school and I'll ask him to give you a break.
just help me if you can and leave the emails for tomorrow
Reputation Points: 10
Solved Threads: 0
Newbie Poster
sotiris25s is offline Offline
4 posts
since Jan 2009
Jan 22nd, 2009
0

Re: can you help me on this problem please?

Click to Expand / Collapse  Quote originally posted by sotiris25s ...
just help me if you can and leave the emails for tomorrow
Are you this moronic by birth or do you practice day by day?
Don't you remember when your teacher told you that cheating was not good for you?

We don't give school assignment solutions. You would have known that, if you took the time to read the rules of this forum.
Last edited by Aia; Jan 22nd, 2009 at 6:52 pm. Reason: Changing a word.
Aia
Reputation Points: 2224
Solved Threads: 218
Nearly a Posting Maven
Aia is offline Offline
2,304 posts
since Dec 2006
Jan 22nd, 2009
0

Re: can you help me on this problem please?

Click to Expand / Collapse  Quote originally posted by Aia ...
Are you this moronic by birth or do you practice day by day?
Don't you remember when your teacher told you that cheating was not good for you?

We don't give school assignment solutions. You would have known that, if you took the time to read the rules of this forum.
so if i write some of the code that i have in mind will you help me solve it?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
sotiris25s is offline Offline
4 posts
since Jan 2009
Jan 22nd, 2009
0

Re: can you help me on this problem please?

Click to Expand / Collapse  Quote originally posted by sotiris25s ...
so if i write some of the code that i have in mind will you help me solve it?
The premise behind this forum is this; to help people that help themselves.
I doubt you make the cut. However, you will always be "encouraged" to show your efforts and to make explicit where you are having troubles with.
Last edited by Aia; Jan 22nd, 2009 at 7:08 pm.
Aia
Reputation Points: 2224
Solved Threads: 218
Nearly a Posting Maven
Aia is offline Offline
2,304 posts
since Dec 2006
Jan 22nd, 2009
0

Re: can you help me on this problem please?

Click to Expand / Collapse  Quote originally posted by Aia ...
The premise behind this forum is this; to help people that help themselves.
I doubt you make the cut. However, you will always be "encouraged" to show your efforts and to make explicit where you are having troubles with.
  1. #include <stdio.h>
  2. #include <string.h>
  3. #define N 100
  4. #define M 6
  5. main()
  6. {
  7. int i,j surname[N],name[N],ID[N],grade[M][N];
  8.  
  9. for (i=0; i<=N; i++)
  10. { printf("give name,surname,id of %d student",i+1);
  11. scanf("%s",name,surname,id)
  12. {
  13. for (j=0; j<=M; j++)
  14. printf("give grade for the %d lesson,j+1);
  15. scanf("%s",grade[i][j]);
  16. }
  17. if (grade [i][j]>0&&grade[i][j]<10)
  18. {
  19. for (i=0; i<N; i++)
  20. {sum=0;
  21. for (j=0; j<M; j++)
  22. sum=sum+grade[i][j];
  23. avg=sum/6;
  24.  

is ti correct so far?????????
Reputation Points: 10
Solved Threads: 0
Newbie Poster
sotiris25s is offline Offline
4 posts
since Jan 2009
Jan 22nd, 2009
0

Re: can you help me on this problem please?

>is ti correct so far?????????
No! Not at all.
int i,j, surname[N],name[N],ID[N],grade[M][N]; Tell me! What type should be the memory that will hold a name or surname? And grade?

scanf("%s",name,surname,id) Three type of variables, but I only see one "%s" format operator.

scanf("%s",grade[i][j]); At best, grade[i][j] would be a single char or int, which can not receive a formatted "%s".
Aia
Reputation Points: 2224
Solved Threads: 218
Nearly a Posting Maven
Aia is offline Offline
2,304 posts
since Dec 2006
Jan 22nd, 2009
0

Re: can you help me on this problem please?

(*rats I wasn't first reply *)

int i,j surname[N],name[N],ID[N],grade[M][N]; Declares all of those variables as integer. Should some of them have character data?

The format in scanf("%s",name,surname,id) will only read one string value. surname and id will be empty. (But as noted above, name, surname and id are all integers anyway.)

This for statement:
  1. for (j=0; j<=M; j++)
  2. printf("give grade for the %d lesson,j+1);
  3.  
does not have any braces on it and so will loop only the first statement.

You don't have enough matching braces yet, could you try to compile it and post code that compiles?

and when posting c code, please use c code tags
[code=c]
/* Your code here */
[/code]
Reputation Points: 344
Solved Threads: 116
Practically a Master Poster
Murtan is offline Offline
670 posts
since May 2008
Jan 23rd, 2009
0

Re: can you help me on this problem please?

@ sotiris25s
You need to go basics throughly.
Reputation Points: 6
Solved Threads: 9
Junior Poster in Training
ajay.krish123 is offline Offline
90 posts
since Nov 2008

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: numbers from file to array
Next Thread in C Forum Timeline: converting string to MAC address structure





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


Follow us on Twitter


© 2011 DaniWeb® LLC