Returning grades from the function

hello I am having a problem with my program I am practicing on trying to return how many A, B, C, D, and F there were but forgot how to bring back more then one thing in the function please help

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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
  #include <iostream>
using namespace std;
void input (int [],int);
int checking(int [],int);

int main ()
{
	int size, *arr;
	cout <<"How many test were there?";
	cin >> size;
	arr= new int [size];
	input (arr, size);
	checking (arr,size);
	cout <<"A's :" << A;
	cout <<"B's :" << B;
	cout <<"C's :" << C;
	cout <<"D's :" << D;
	cout <<"F's :" << F;
	return 0;
}
void input (int ar[],int size)
{
	for (int x = 0; x < size; x++)
	{
		cout <<"Please type in each score now :";
		cin >> ar[x];
	}
}
int checking (int ar[],int size)
{
	int A = 0;
	int B = 0;
	int C = 0;
	int D = 0;
	int F = 0;
	for (int x = 0; x < size; x++)
	{
		if (ar[x] < 59)
			F++;
		else if (ar[x] < 70 && ar[x] > 59)
			D++;
		else if (ar[x] > 69 && ar[x] < 79)
			C++;
		else if (ar[x] > 79 && ar[x] < 89)
			B++;
		else if (ar[x] > 89)
			A++;
	}
	return A,B,C,D,F;
}
You cannot return multiple values or an array, but you can have an array parameter:
void checking( const int ar[], int size, int grades[] );
ah gotcha thanks :D
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <iostream>
using namespace std;
void input (int [],int);
void checking(int [],int);

int main ()
{
	int size, *arr;
	cout <<"How many test were there?";
	cin >> size;
	arr= new int [size];
	input (arr, size);
	checking (arr,size);
	return 0;
}
void input (int ar[],int size)
{
	for (int x = 0; x < size; x++)
	{
		cout <<"Please type in each score now :";
		cin >> ar[x];
	}
}
void checking (int ar[],int size)
{
	int A = 0;
	int B = 0;
	int C = 0;
	int D = 0;
	int F = 0;
	for (int x = 0; x < size; x++)
	{
		if (ar[x] < 59)
			F++;
		else if (ar[x] < 70 && ar[x] > 59)
			D++;
		else if (ar[x] > 69 && ar[x] < 79)
			C++;
		else if (ar[x] > 79 && ar[x] < 89)
			B++;
		else if (ar[x] > 89)
			A++;
	}
	cout <<"A's :" << A << endl;
	cout <<"B's :" <<  B << endl;
	cout <<"C's :" << C << endl;
	cout <<"D's :" << D << endl;
	cout <<"F's :" << F << endl;
}
Topic archived. No new replies allowed.