Question about void pointers

Hi so one of the question on my lab explains to grade my pointer array into
a passing or failing.

Then the array should be passed to a function that calculates the number of passing scores (i.e. the score was 60 or above) and the number of failing scores (below 60).
Here is the function header:

void passOrFail(double* stuScores, int numScores, int & pass, int & fail)
{


//code to calculate the number of passing/failing scores

}

The program should then display the number of passing and failing grades from main().


I'm actually confused at this step, even though I should make a for( if statement), i don't understand how to properly code it with a pointer/array.


You could do it like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <iostream>
#include <string>

using namespace std;

void passOrFail (double* stuScores, int numScores, int & pass, int & fail)
{


  //code to calculate the number of passing/failing scores

}

int main () 
{
  double scores[] = {10, 90, 55, 77 /*etc.*/};
  const int NUM_SCORES = sizeof (scores) / sizeof (scores[0]);
  int num_pass = 0, num_fail = 0;

  passOrFail (scores, NUM_SCORES, num_pass, num_fail);

  cout << "Result" << "\n";
  cout << "Passed: " << num_pass << "\n";
  cout << "Failed: " << num_fail << "\n";
  system ("pause");
  return 0;
 
}
Topic archived. No new replies allowed.