For starters, you really need to work on your formatting, it's very hard to understand your code.
Second, this:
for(int a=0;a<15;a++){
cout<<"enter value num #:"<<a<<endl;
cin>>nums[a];
checknum[a]=nums[a];
}
is going to cause errors. You are running from 0-14, which attempts to store 15 elements. Since your arrays only have 14 elements you need to limit your range to 0-13. You have the same basic error on all 4 of your loops.
If you have an array of SIZE elements, your array indexes will be 0 thru (SIZE-1). If you try to use SIZE as an index, you will overrun the boundaries of the array and most likely cause issues.
Correct your loops, then see how things go.
Fbody
Posting Maven
2,930 posts since Oct 2009
Reputation Points: 833
Solved Threads: 393
int nums[14],checknum[14],displaynum[14] is how you've declared your arrays, with 14 total elements. Your loop goes 0,1,2,...,14 which is 15 elements.
jonsca
Quantitative Phrenologist
5,621 posts since Sep 2009
Reputation Points: 1,165
Solved Threads: 581
And I'm the second one to agree with FBody. Do you still think he's wrong?
WaltP
Posting Sage w/ dash of thyme
10,505 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944
thnkx dude..but i think u r wrong...array0-14 stores 15 elements ..............1-14 stores 14 +array[0] stores a element.....
In some languages, SIZE specifies the last element's index, but it's not not the case in C and C++.
Observe:
'this example is valid in most BASIC dialects
Dim SIZE as const integer = 4
Dim myArray(SIZE) as integer
'generates indexes 0 thru SIZE
'i.e. indexes 0,1,2,3,4
//this example applies to all C++
const int SIZE = 4;
int myArray[SIZE];
//generates indexes 0 thru (SIZE-1)
//i.e. indexes 0,1,2,3
//notice: there is no index 4, attempting to access is an error
Read up on arrays , fix your loops, then give us an update.
Fbody
Posting Maven
2,930 posts since Oct 2009
Reputation Points: 833
Solved Threads: 393