![]() |
Simple program but I am unsure how to fix it
I wonder if anyone can see where I'm going wrong? What I am trying to do is get a student name, get their two scores then it works out a grade (Pass,merit,fail) based on the addition of the two scores. Then it must loop 5 times to get 5 student names.
On the first loop everything works fine, but when it gets to the second it will display "Fail" no matter what combination of numbers I put in. Also it will not display the error message if I go over 50 (on the second attempt - works fine on the first) I'm pretty new to this, so any helpful guidance would be greatly apprieciated :) Code:
#include <stdio.h> |
Re: Simple program but I am unsure how to fix it
There are quite a few errors in the program. I am mentioning the one I just saw when I looked at it.
1. scanf for string should be %s instead of %c. 2. score function you are using the variable i which is never initialized. 3. You are taking the input in score1 the scores but comparing with score1[i] where i is never initilaized. 4. Same is the case in score1 5. similar things are observed in grade function as wel. I think the above points will help you rectify the problem you are facing. |
| All times are GMT +5.5. The time now is 21:20. |