Help need to enter void

...
Last edited on
What do you mean? Where are your void functions?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
	int scores;
	cout<<"Please enter five test scores"<<endl;

	cin>>scores;

	cin>>scores;

	cin>>scores;

	cin>>scores;

	cin>>scores;

	double average = (scores+scores+scores+scores+scores)/5;


Should be :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
	int scores, total = 0;
	cout<< "Please enter five test scores : " << endl;

	cin>>scores; total += scores;

	cin>>scores; total += scores;

	cin>>scores; total += scores;

	cin>>scores; total += scores;

	cin>>scores; total += scores;

	double average = (total) / 5.0;
Last edited on
here, i try this but it does not work properly



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
51
52
53
54
55
56

#include <iostream>
#include <iomanip>
using namespace std;

void input (int grade, int add, int gradeone, int gradetwo, int gradethree, int gradefour, int gradefive) {
	cout<<"Input five grades "<<endl;
	cin>>gradeone;
	cin>>gradetwo;
	cin>>gradethree;
	cin>>gradefour;
	cin>>gradefive;

    double average= (gradeone+gradetwo+gradethree+gradefour+gradefive)/5;

}

int main () {

double average;

  if( average < 60)
	{
		cout<<"Your average is an F."<<endl;
	}
	else if( average >= 60 && average<= 69)
	{
		cout<<"Your average is a D."<<endl;
	}
	else if( average >= 70 && average<= 79)
	{
		cout<<"Your average is a C."<<endl;
	}
	else if( average >= 80 && average <= 89)
	{
		cout<<"Your average is a B."<<endl;
	}
	else if( average >= 90 && average<= 100)
	{
		cout<<"Your average is an A."<<endl;
	}

	else
	{
		cout<<"you are bad student with no grades"<<endl;
	}
return 0;
}
void output(double average){

    cout.setf(ios::showpoint|ios::fixed);
    cout<<setprecision(1);

    cout<<"Your grade Average is "<<setw(8)<<average <<endl;

}

1
2
3
4
5
6
7
8
9
10
11
void input (int grade, int add, int gradeone, int gradetwo, int gradethree, int gradefour, int gradefive) {
	cout<<"Input five grades "<<endl;
	cin>>gradeone;
	cin>>gradetwo;
	cin>>gradethree;
	cin>>gradefour;
	cin>>gradefive;

    double average= (gradeone+gradetwo+gradethree+gradefour+gradefive)/5;

}


Should be :
1.
1
2
3
4
5
6
7
8
9
10
11
void input (double &average) {
        int gradeone; int gradetwo; int gradethree; int gradefour; int gradefive;
	cout<<"Input five grades "<<endl;
	cin>>gradeone;
	cin>>gradetwo;
	cin>>gradethree;
	cin>>gradefour;
	cin>>gradefive;

    average= (gradeone+gradetwo+gradethree+gradefour+gradefive)/5;
}


2.
1
2
3
4
5
int main () {

double average;

input(average);


Where in your code did you call the function input()??
Tysm

I got it now..
Topic archived. No new replies allowed.