I was wondering if anybody could help me find the problem in my logic. I'm creating a mathmatics program for adding/subtracting integer arrays. I believe the logic error would be on one of the sorts or in the calculation itself. below is my code for a simple self made sort to reverse the integers.
I feel that the logic on this is sound. Another spot that I'm thinking has issues is this below math equations for addition and subtraction.Code:for (x=Count2;x>=0;x--) { if (!(HugeInteger2[x]=='\r')) { ReOrder2[ReOrderCount2]=HugeInteger2[x]-48; ReOrderCount2++; } }
The basic idea of what i'm trying to do is create and input a char array that gets interprited like an integer array (ints stored in ascii value). I do my calculations like equality, greatness and other misc calculations (add, subtract, devide, etc.).Code:for(x=0;x<=SIZE;x++) { if (ReOrder1[x]>='0'&&ReOrder1[x]<='9' &&ReOrder2[x] >='0'&&ReOrder2[x]<='9') { if (ReOrder1[x]=='\0') Add1=0; else Add1=ReOrder1[x]-48; if (ReOrder2[x]=='\0') Add2=0; else Add2=ReOrder2[x]-48; Addition[x] = Add1+Add2+AddCarry; Add++; if ( Addition[x] > 9 ) { Addition[x] %= 10; AddCarry = 1; } else AddCarry = 0; } }
(1) Does this code show any obvious logic error?
(2) Where and how?