I am trying to give an array some values and print them out ..

I initialise the elements to zero first .. after that I put values in .. then try print them out ..

the code compiles and runs .. Im getting the wrong values though so if anyone could spot where the error is I would appreciate it thanks ..

this is my code.

and a sample run returns these valuesCode:#include<iostream> using namespace std; int main( int argc, char **argv){ long double arrayA[1]; long double arrayB[1]; long double arrayC[1]; // initialise all elements in array to zero and check this happens arrayA[0] = 0; arrayA[1] = 0; cout<< "initial arrayA" << "\n" << arrayA[0] <<"\n"; cout<< "initial arrayA" << "\n" << arrayA[1] <<"\n"; arrayB[0] = 0; arrayB[1] = 0; cout<< "initial arrayB" << "\n" << arrayB[0] <<"\n"; cout<< "initial arrayB" << "\n" << arrayB[1] <<"\n"; arrayC[0] = 0; arrayC[1] = 0; cout<< "initial arrayC" << "\n" << arrayC[0] <<"\n"; cout<< "initial arrayC" << "\n" << arrayC[1] <<"\n"; // that worked out fine so now put values in array and check that they are // ok .. arrayA[0] = 3; arrayA[1] = 6; cout<< "mid arrayA" << "\n" << arrayA[0] <<"\n"; cout<< "mid arrayA" << "\n" << arrayA[1] <<"\n"; arrayB[0] = 9; arrayB[1] = 12; cout<< "mid arrayB" << "\n" << arrayB[0] <<"\n"; cout<< "mid arrayB" << "\n" << arrayB[1] <<"\n"; arrayC[0] = 15; arrayC[1] = 18; cout<< "mid arrayC" << "\n" << arrayC[0] <<"\n"; cout<< "mid arrayC" << "\n" << arrayC[1] <<"\n"; // that worked ok final check to make sure cout<< "last arrayA" << "\n" << arrayA[0] <<"\n"; cout<< "last arrayA" << "\n" << arrayA[1] <<"\n"; cout<< "last arrayB" << "\n" << arrayB[0] <<"\n"; cout<< "last arrayB" << "\n" << arrayB[1] <<"\n"; cout<< "last arrayC" << "\n" << arrayC[0] <<"\n"; cout<< "last arrayC" << "\n" << arrayC[1] <<"\n"; return(0); }

initial arrayA

0

initial arrayA

0

initial arrayB

0

initial arrayB

0

initial arrayC

0

initial arrayC

0

mid arrayA

3

mid arrayA

6

mid arrayB

9

mid arrayB

12

mid arrayC

15

mid arrayC

18

last arrayA incorrect value here

12

last arrayA

6

last arrayB and incorrect value here

18

last arrayB

12

last arrayC

15

last arrayC

18

thanks again any help appreciated al.