Thank You for reading this.
I am new to c++ and I wrote this code to see if it will work but it doesnt. could you please tell me why it doesnt work or is there a easier way of doing it. I wanted to make a function to get the results but I am not sure how to use functions yet.
The code is supposed to get competitors scores and average them. Then all the competitors below average are to be assigned -999 and then all of them to be printted out.
But it doesnt work.
Please tell whats wrong or how to use functions to get the results.
I am new to this so please explain in easy language.
I thank you in advance
Eric

#include <iostream.h>
#include <stdio.h>
main()
{

int num[5];
int sum;
float average;

for( int i=0; i<5; ++i )
{
cout<<"Enter competitors score: ";
cin>>num[i];
}

for( int x=0; x<5; ++x )
{
sum += num[x];
}

average = sum/5;

for( int y=0; y<5; ++y )
{
if ( num[y]<average )
num[y]= -999;
}

for( int z=0; z<5; ++z )
{
if ( num[z]!= -999 )
cout<<"These competitors scored above average: "<<num[z];
cout<<"\n";
}

for( int c=0; c<5; ++c )
{
if ( num[c]== -999 )
cout<<"These competitors scored below average: "<<num[c];
cout<<"\n";
}

cout<<"End of program";

return 0;
}