How Can I Write This Program to Create Arrays Using Pointers for Exam Scores?

I have homework that I put off to the last minute, need some help coding this program that is due tonight. I have a very bare minumum skeleton started, but I need help getting suggestions on how to set up the program when I get home tonight after work. I need help in setting up the rest of the program. I did google this homework assignment and found a couple of results that were slightly helpful, but I need more help than that.

I am having to go to work now, but I would have coded more of this program.

I am writing a program that uses dynamic memory location to create two arrays by using the user's input of the number of students taking an exam (array size is 5). And this input is to be used to create two arrays. One array to store the student ID numbers, and the second parallel array to store the student's entrance exam scores.

Here's what I found so far:
https://stackoverflow.com/questions/33426625/c-dynamically-allocate-an-array-bubblesort-finding-average

http://www.cplusplus.com/forum/beginner/20287/


I need to create a function to allow the user to enter in the student id number and the student's exam score (between 0-1500) and validate the input. I need to create functions to calculate the exam average for all of the students in this class, find the highest exam score and to display the student id number along with the highest exam score, and also to find the lowest exam score displayed with the student id number.

Also, I need to use pointers for array processing.

#include <iostream>

using namespace std;

// function prototypes
void welcome();
const int studIdNum
const int studExmScore


int main()
{
numOfStudents;
return 0;
}


use new.
for an integer 'array' from a pointer, for example...
int size = 1234; //you can read this from cin
int *array = new int[size];
...
array[x] = y; //looks just like an array to use it
...
delete[] array; //required once done with the variable to release memory to OS every new statement has a delete statement just like every { has a } to close

----------
there are handy shortcuts with pointers and arrays.
int blah[1000];
int* pb = blah; //pb[0] and blah[0] are the same memory location / they are the same thing!
pb = &blah[20]; // pb[20] is the same as blah[20] as above. handy sometimes.
dunno what else you might need. But those are the basics.
The first steps of this will be:

1) Prompt the user to input the number of students
2) Read the user's input
3) Use that input to dynamically allocate the two arrays with the correct size
4) Create a function that does the following:
a) Prompt the user to enter a student ID number
b) Read the user's input
c) Prompt the user to enter the exam score
d) Read the user's input
e) Validate the user's inputs
f) If valid, store the user's inputs in the arrays

Until you provide more detail about what, specifically, you're having trouble with, there's not much point trying to say anything more specific.
Last edited on
pb = &blah[20]; // pb[20] is the same as blah[20] as above. handy sometimes.


@jonnin had a slight typo. Should be: pb[0] is the same as blah[20].
yes. sorry!
Thank you guys! All of those suggestions are very helpful for me in coding this program!
You're welcome - glad it helped.
Topic archived. No new replies allowed.