Okay I have been stuck on this code for about a week, and my professor is not really helping me so I thought I would go here. This is what I have to do : Using the flowchart for Lab #08 as a guide, write a C++ program that does the same
thing. Your C++ program must also use procedures (called functions in C++) to input the
student responses, and determine how many answers were correct.
Remember Raptor arrays start at 1, but C++ arrays start at 0.
Here is what the function header for inputAnswers should look like;
void inputAnswers(int givenAnswers[ ] )
The numberCorrect function should return an int.
I have been stuck on comparing them. I have found several codes that do almost the same, but every time I tried making it like mine with the required code parts it breaks it. If y'all could explain to me what I need and do not need that would be sooo helpful! Thank you!
Using the flowchart for Lab #08 as a guide, write a C++ program that does the same
thing.
How many of us do you think have seen your "flowchart for Lab #08"? It's much easier for us to help you with your problems if we don't have to figure out for ourselves what it is you're trying to do.
A couple of things jump out at me from your code:
1) At line 52, you're trying to compare a single int, with an array. That makes no sense. Does that even compile? Is your compiler not giving you a warning about that?
You'll need to go through the contents of correctAnswers, and check givenAnswers[count] against each value.
2) Also at line 52. do you know the difference between = (assignment) and == (comparison) ?
3) Look at the return statement at line 57. When do you think your function will return? How many times do you think your loop will iterate before the function returns?
Your function is called numRight(). It sounds like it should be called numberCorrec(). This is a small detail, but why take a chance on losing points because of a small detail?
Your numRight() function computes the number of questions right, and then converts to a percentage, and then displays the result, and then pauses the program. It's good practice to have one function do one thing, so I suggest that numRight() should just compute how many answers were correct and return that value. Then inside main() you can convert to a percentage, display the result and pause the program.
Thank y'all for the replies. Yes I have figured out the code, and I did not realize some of the mistakes that were written in the above code because like I said I have been doing many things to this code. I have fixed most of the mistakes. I'll post the code so that y'all can see it! Thank you again for y'alls help