Hi,
What's wrong with this code:
//Comments explain what I check
int Array[9]={1,2,3,4,5,6,7,8,9};
int Integer=0;
int i=8,n=0;
for(int x=0;x<9;x++)
cout<<"array="<<Array[x]<<endl; //Are all members ok?
for(int exp=0;i>=0;i--){
Integer+=Array[i]*pow(10,exp);
cout<<"Integer1="<<Integer<<endl; //Is Integer being summed fine?
exp++;
}
cout<<"Integer="<<Integer<<endl;
Program's function is to create an integer from array ( for example: if array has 1,2,3; it need to make integer 123 ).
The problem is terrible:
If I have 3-4 members of array my result will decrement during 3rd summing.
If I have 5-6 members result will decrement during 3rd and 5th summing.
If I have 7 members result will decrement during 5th summing.
If I have 8 members result will decrement during 3rd summing.
If I have 9 members result will decrement during 3rd, 5th and 9th summing.
( I haven't removed cout-checks so you can see what I do )
What is the problem??
Thanks a lot, I'm lost.