i am trying to avg scores but i keep getting errors, can someone please help me.

#include "stdafx.h"   
#include <iostream>
using namespace std;

const int SIZE =3;


int main()
{
	int sum=0;
	int tests[SIZE]={0};
	float average;
	
	char terminate;

	cout<<" Enter test1:";
	cin>> tests[0];

	cout<<"Enter test2:";
	cin>> tests[1];

	cout<<" Enter test3:";
	cin>> tests[2];

	sum = tests[0]+ tests[1]+ tests[2];
		
	cout<< tests[0];

	average= (test1 + test2 + test3)/3;

	cout<< "The average is" <<average <<endl;
	
	cout<<" Enter any character to terminate:";
	cin>> terminate;

	
	
	return 0;
}
average= (tests[0] + tests[1] + tests[2])/3; // assumed fixes
cout<< "The average is" <<average <<endl;

Lemme guess -- no decimal places? Dividing integers uses integer division. If you want a floating point value, cause floating point division.

average= (tests[0] + tests[1] + tests[2])/3.0; // assumed fixes

Edited 3 Years Ago by pyTony: fixed formatting

and scrap #include "stdafx.h" as it's not needed... Never understand why MSVC adds that to everything.
Also add #include <iomanip> or you'll never get a clean compile. endl is defined there.

#include <iostream.h>

const int SIZE =3;

float sum;
float tests[SIZE]={0};
float average;
char terminate;


void main()
{
    cout<<" Enter test1:";
    cin>> tests[0];

    cout<<"Enter test2:";
    cin>> tests[1];

    cout<<" Enter test3:";
    cin>> tests[2];

    sum = tests[0]+ tests[1]+ tests[2];


    average= sum / 3;

    cout<< "The average is" <<average <<endl;

    cout<<" Enter any character to terminate:";
    cin>> terminate;


}

Edited 3 Years Ago by Dani: Formatting fixed

and scrap #include "stdafx.h" as it's not needed... Never understand why MSVC adds that to everything.
Also add #include <iomanip> or you'll never get a clean compile. endl is defined there.

Just a note:

// These are from <iomanip> as per [27.6].  Manipulators from <istream>
// and <ostream> (e.g., endl) are made available via <iostream.h>.
This question has already been answered. Start a new discussion instead.