{ int num1[255], num2[255], sum[255]; //char s1[] = , s2["123456789123456789"]; char s1[] = "62167219200"; char s2[] = "1636511102"; char concat[1000]; int l1, l2; int carry, k, i, j; /* convert character to integer*/ for (l1 = 0; s1[l1] != '\0'; l1++) { num1[l1] = s1[l1] - '0'; } for (l2 = 0; s2[l2] != '\0'; l2++) { num2[l2] = s2[l2] - '0'; } carry = 0; k = 0; i = l1 - 1; j = l2 - 1; for (; i >= 0 && j >= 0; i--, j--, k++) { sum[k] = (num1[i] + num2[j] + carry) % 10; carry = (num1[i] + num2[j] + carry) / 10; } if (l1 > l2) { while (i >= 0) { sum[k++] = (num1[i] + carry) % 10; carry = (num1[i--] + carry) / 10; } } else if (l1 < l2) { while (j >= 0) { sum[k++] = (num2[j] + carry) % 10; carry = (num2[j--] + carry) / 10; } } else { if (carry > 0) sum[k++] = carry; } sprintf(concat, "%s", ""); lr_output_message("concat is %s", concat); lr_output_message("Result:"); for (k--; k >= 0; k--) { sprintf(concat, "%s%d", concat, sum[k]); } lr_output_message("%s", concat); return 0; }