Add two strings representing numbers Carry = 0 S1 = S2 = S3 =
Add two strings representing numbers Carry = 0 S1 = S2 = S3 = First iteration ( i=1 ): n1 = S1(length(S1)+i-1)-'0';
Add two strings representing numbers Carry = 0 S1 = S2 = S3 = First iteration ( i=1 ): n2 = S2(length(S2)+i-1)-'0';
Add two strings representing numbers Carry = 0 S1 = S2 = S3 = First iteration ( i=1 ): n = n1 + n2 + Carry; 1 4
Add two strings representing numbers Carry = 1 S1 = S2 = S3 = First iteration ( i=1 ): Carry = floor(n/10); 1 4
Add two strings representing numbers Carry = 1 S1 = S2 = S3 = First iteration ( i=1 ): tmp = char(mod(n,10)+'0'); 1 4 tmp
Add two strings representing numbers Carry = 1 S1 = S2 = S3 = First iteration ( i=1 ): S3 = [tmp S3]; 1 4 4
Add two strings representing numbers Carry = 1 S1 = S2 = S3 = Second iteration ( i=2 ): 4
Add two strings representing numbers Carry = 1 S1 = S2 = S3 = Second iteration ( i=2 ): n1 = S1(length(S1)+i-1)-'0'; 4
Add two strings representing numbers Carry = 1 S1 = S2 = S3 = Second iteration ( i=2 ): n2 = S2(length(S2)+i-1)-'0'; 4
Add two strings representing numbers Carry = 1 S1 = S2 = S3 = Second iteration ( i=2 ): n = n1 + n2 + Carry; 4 1 0
Add two strings representing numbers Carry = 1 S1 = S2 = S3 = Second iteration ( i=2 ): n = n1 + n2 + Carry; 4 1 0
Add two strings representing numbers Carry = 1 S1 = S2 = S3 = Second iteration ( i=2 ): Carry = floor(n/10); 4 1 0
Add two strings representing numbers Carry = 1 S1 = S2 = S3 = Second iteration ( i=2 ): tmp = char(mod(n,10)+'0'); tmp
Add two strings representing numbers Carry = 1 S1 = S2 = S3 = Second iteration ( i=2 ): S3 = [tmp S3];
Add two strings representing numbers Carry = 1 S1 = S2 = S3 = Third iteration ( i=3 ): 40