Continuous Loop - How to End?
Hi there. I'm trying to create a program that calculates a number of students' GPAs based off of the number of classes and grades they provide. It won't calculate the GPA correctly (probably something to do with assigning the grade points in the switch loop) and then it creates an infinite loop. Please let me know what I am doing wrong? Thanks!
Voters
There is quite a bit wrong with your code. Here is some feedback:
for
loop in main that asks for the student's ID then calls the averaging function which returns the GPA. The number of times this function is called is equal to the number of students in the class. Each student's GPA and ID can be printed out from inside thisfor
loop.break
statement after it - look up a reference on how to use a switch in Cgetchar
function to clear the newline character from the buffer after each call toscanf
. The newline (\n) is automatically put there when the user presses the Enter key.Reply to this post if you want me to look over your code again. All the best. C is hard isn't it! Python is so much easier to learn.