Evrardo
June 4th, 2002, 07:31 PM
I wrote a simple program to find out some things about arrays. I found out what I needed to know, except when I cout the array, it gives me some weird numbers at the very end. I was just wondering if there is a problem with my code or what I can do to get rid of it. here's the code:
____________________________________________________
#include <iostream.h>
const int SIZE=10;
void main()
{
int array[SIZE]={0};
int value, num1, i;
cout <<"Enter the section of the array:\n";
cin >>value;
cout <<"Enter the number to go into that section:\n";
cin >>num1;
array[value]=num1;
for(i=0; i<=SIZE; i++)
{
cout <<array[i] <<endl;
}
}
____________________________________________________
#include <iostream.h>
const int SIZE=10;
void main()
{
int array[SIZE]={0};
int value, num1, i;
cout <<"Enter the section of the array:\n";
cin >>value;
cout <<"Enter the number to go into that section:\n";
cin >>num1;
array[value]=num1;
for(i=0; i<=SIZE; i++)
{
cout <<array[i] <<endl;
}
}