Hello all, I am getting a few errors with my code, I have been playing around with it but I guess I still needed a few tweaks. The errors and code are as follows:
23 C:\myC++projects\averageproj.cpp expected `;' before '}' token
27 C:\myC++projects\averageproj.cpp expected primary-expression before '<<' token
34 C:\myC++projects\averageproj.cpp expected `}' at end of input
#include <iostream>
using namespace std ;
int main ()
{
int Age[50] ; // age of personnel
int I ; // number of ages entered
int sum ; // sum of ages
float Average ; // average of ages entered
sum = 0 ;
Average = 0 ;
for (I = 0 ; I < 50 ; I++)
{
cout << "Enter current age of AD Navy Personnel" << ( I + 1 ) << endl ;
cin >> Age[I] ;
if ( Age[I] >=18 ){
sum = sum + Age[I] ;
}
else {
I = 1 // the same element the Age array will be read ;
}
Average = sum/50 ;
for ( I = 0 ; I < 50 ; I ++ )
{
cout << "Age of Personnel" + << ( I + 1 ) << "is : "
<< Age[I] << endl ;
}
cout << "The current average age of AD Navy Personnel is : "
<< Average << endl ;
return (0); // terminate with success
}