When i run my code an error pops up and its say something about the declaration of my variable "SIZE". i have tried numerous ways to solve this problem but i have given up. does somebody know whats wrong with it?
// ConsoleApplication1.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <windows.h>
usingnamespace std;
constint SIZE = 5;
void getScores(float testScores[SIZE]);
void showMenu();
char getChoice(char choice);
float displayResult(char choice, float testScores[SIZE]);
/*
*
*/
int main(int argc, char** argv) {
float testScores[SIZE];
char choice;
getScores(testScores);
system("CLS");
showMenu();
choice = getChoice(choice);
system("CLS");
displayResult(choice, testScores);
return 0;
}
void getScores(float testScores[SIZE])
{
cout << "what are the 5 test scores? " << endl;
for (int i = 0; i < 5; i++)
{
cin >> testScores[i];
}
}
void showMenu()
{
cout << " A.) Calculate the average of the test scores. " << endl;
cout << " B.) Display all test scores. " << endl;
}
char getChoice(char choice)
{
char letter;
cout << " Please enter a choice ";
cin >> letter;
return letter;
}
float displayResult(char choice, float testScores[SIZE])
{
float sum = 0;
float average = 0;
for (int i = 0; i < 5; i++)
{
sum += testScores[i];
}
average = sum / 5;
cout << fixed << showpoint << setprecision(2) << endl;
if (toupper(choice) == 'a')
{
cout << "your average is " << average << endl;
}
elseif (toupper(choice) == 'b')
{
cout << "These are your TestScores " << endl;
for (int i = 0; i < 5; i++)
{
cout << testScores[i] << endl;
}
cout << endl;
}
else
cout << "It is invalid" << endl;
}
error output
1 2 3 4 5 6 7 8 9
1>c:\users\gears\documents\visual studio 2013\projects\consoleapplication1\consoleapplication1\consoleapplication1.cpp(13): error C2377: 'SIZE' : redefinition; typedef cannot be overloaded with any other symbol
1> c:\program files (x86)\windows kits\8.1\include\shared\windef.h(190) : see declaration of 'SIZE'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========