Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

stack aroud the varable A is corrupted

$
0
0
I am getting this error every time i try to run the program.


Question : ask the user to enter 10 numbers, then find their average, then show only numbers Smaller than Average.




#include<iostream>
using namespace std;

int main()
{

const int  Numbers = 10;   //Declar size of the array
int A[Numbers];
int i;
double Average;            
cout<<"Enter 10 numbers"<<endl;

for (i=0;i<Numbers; i++)
{

cin>>A[Numbers];
Sum = +A[Numbers];


}


for (i=0;i<10;i++)
Average = Sum/Numbers;
if (A[Numbers] < Average)cout<<A[Numbers]<<"\t\t";


return 0;

}








I also tried changing
A[Numbers] with A[i] 
for all codes , which worked but showed random number -8354353

Thank you in advance for your help

Viewing all articles
Browse latest Browse all 51036

Trending Articles