Help for tomorrow's exam - program that can read in exam results

In summary, the conversation involves a student asking for help with a programming project that involves reading and summing exam results, looking for repeat numbers, and using arrays. The language being used is C++ and the student is looking for a way to handle an unknown quantity of inputs without declaring it beforehand. The expert suggests using a large floating-point number for the sum and implementing error checking to avoid memory issues.
  • #1
AstroIreland
12
0
Hey guys, I am studying astrophys but i have a programming module, so hopefully this is the right place to ask.

I have a few questions that I am having difficulty with so I am going to pose it in the form of a program if that's cool? I can then take it apart to see how its done.
I'd appreciate it if someone has the time!

So, I need a program that can read in exam results that are in putted (the input is in-between 0 to 100) and it is an unknown number of exam results to be inputted.
The program is to look for a repeat number that has been typed in before.

So for example the numbers may be inputted for the next 4000 years until the same two come up.
So how would I go about the program (maybe using arrays?) that can keep accepting inputs to an unknown quantity. When the matching pair of results are found, I would then like all of the user inputted results to be summed and printed to screen.

Any ideas?
Thanks in advance!
 
Physics news on Phys.org
  • #2
oh, it could be 4000 years or 2 minutes, its the infinite storing array until the match comes up I am having issues with!
 
  • #3
AstroIreland said:
Hey guys, I am studying astrophys but i have a programming module, so hopefully this is the right place to ask.

I have a few questions that I am having difficulty with so I am going to pose it in the form of a program if that's cool? I can then take it apart to see how its done.
I'd appreciate it if someone has the time!

So, I need a program that can read in exam results that are in putted (the input is in-between 0 to 100) and it is an unknown number of exam results to be inputted.
The program is to look for a repeat number that has been typed in before.

So for example the numbers may be inputted for the next 4000 years until the same two come up.
So how would I go about the program (maybe using arrays?) that can keep accepting inputs to an unknown quantity. When the matching pair of results are found, I would then like all of the user inputted results to be summed and printed to screen.

Any ideas?
Thanks in advance!

Your program requirements are a bit imprecise. Is this close to what you are asking?

** Sum all numbers that are input until you get a 2nd occurrance of the same number input. Numbers are between 0-100.

If so, that's pretty easy to code with finite resources (assuming the sum doesn't grow too large for the size of the summing variable).
 
  • #4
Thanks for your quick response.
Would I just write a simple array and leave the square parenthesis without a constant?
 
  • #5
AstroIreland said:
Thanks for your quick response.
Would I just write a simple array and leave the square parenthesis without a constant?

I don't know what you mean by that, but I'm pretty sure the answer is no.

Do you have a particular computer language in mind for this, or is it a thought experiment to help you figure out some other problem. Even if it's a thought experiment, you should be able to write it up in pseudo-code or C.
 
  • #6
Sorry I didnt specify the language. Yes, it's C++.
It is a question I have devised that would show me how to answer all of my coding questions within the one.
I mean for the initial coding of the array:
eg
int array [];

then the user inputs under cin (continuously until there is a repetition, then sum the numbers.

Know what I mean?
 
  • #7
AstroIreland said:
Sorry I didnt specify the language. Yes, it's C++.
It is a question I have devised that would show me how to answer all of my coding questions within the one.
I mean for the initial coding of the array:
eg
int array [];

then the user inputs under cin (continuously until there is a repetition, then sum the numbers.

Know what I mean?

I'm understanding a little better, but no guarantees... :smile:

You don't need any large array to write the program the way I described it. You just need one large sum variable, and an array of ______ logical elements...
 
  • #8
Yeah, see that's what I mean about the specific sum variable.
I want it so the user can vary e.g different schools use the program so the number of results to be in-putted is unknown.
 
  • #9
If I get what you mean there; it's to put a large number in the array eg
int array [5000];

?

See I would like to be able to have an unknown quantity within the brackets, that does not have to be declared.
 
  • #10
AstroIreland said:
Yeah, see that's what I mean about the specific sum variable.
I want it so the user can vary e.g different schools use the program so the number of results to be in-putted is unknown.

AstroIreland said:
If I get what you mean there; it's to put a large number in the array eg
int array [5000];

?

See I would like to be able to have an unknown quantity within the brackets, that does not have to be declared.

No, do not save the inputs. You only use them to add into an overall sum, and to check to see if they've been input previously.

You can use a large floating-point number for the sum if the number could exceed the capacity of the largest unsigned int variable for the processor you are coding for. Or you could implement your own multi-largest unsigned int variable with your own manual code for doing carrys and so on as the number gets larger. You should always put an upper bound and error checking on any kind of sum like this. A finite processor obviously does not have infinite memory resources.
 
  • #11
berkeman said:
No, do not save the inputs. You only use them to add into an overall sum, and to check to see if they've been input previously.

You can use a large floating-point number for the sum if the number could exceed the capacity of the largest unsigned int variable for the processor you are coding for. Or you could implement your own multi-largest unsigned int variable with your own manual code for doing carrys and so on as the number gets larger. You should always put an upper bound and error checking on any kind of sum like this. A finite processor obviously does not have infinite memory resources.

Thank you for your great reply.
I have had a read over and you have filled in my missing gaps nicely.

I didn't consider large floating points. Cheers!
 

What is "Help for tomorrow's exam"?

"Help for tomorrow's exam" is a program that is designed to read in exam results and provide assistance for students preparing for exams. It uses data analytics and algorithms to analyze past exam results and create customized study plans for each student.

How does "Help for tomorrow's exam" work?

The program works by first reading in the exam results of each student. It then uses data analytics and algorithms to identify patterns and determine areas of weakness for each student. Based on this information, it creates a personalized study plan for the student to help them improve their exam performance.

What makes "Help for tomorrow's exam" different from other study programs?

Unlike other study programs that provide generalized study materials, "Help for tomorrow's exam" uses personalized data to create a customized study plan for each student. This allows for more targeted and effective studying, leading to better exam results.

Is "Help for tomorrow's exam" suitable for all types of exams?

Yes, the program can be used for a wide range of exams, including standardized tests, college entrance exams, and subject-specific exams. It is designed to adapt to different types of exams and provide personalized assistance for each one.

Can "Help for tomorrow's exam" guarantee improved exam results?

While "Help for tomorrow's exam" can provide personalized study plans and assistance, it cannot guarantee improved exam results. Ultimately, the student's effort and dedication to following the study plan will determine their exam performance.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
8
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
7
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
22
Views
4K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
9
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
4
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
7
Views
2K
  • Programming and Computer Science
Replies
3
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
938
  • Engineering and Comp Sci Homework Help
Replies
9
Views
2K
Back
Top