#include main() { unsigned char A[6] = {130, 92, 145, 145, 255, 255 } ; unsigned char B[6] = {155, 71, 145, 145, 0, 0 } ; unsigned char C[7] = {0, 0, 0, 0, 0, 0, 0} ; printf("\nData sizes:\n") ; printf("sizeof(char) = %d\n", sizeof(char)) ; printf("sizeof(short) = %d\n", sizeof(short)) ; printf("\n\n") ; unsigned short int x ; unsigned char carry ; carry = 0 ; for(int i = 0 ; i < 6 ; i++) { x = ( (short) A[i] ) + ( (short) B[i] ) + ( (short) carry ) ; C[i] = x % 256 ; // should use bit operations here printf ("A[%d]=%3d B[%d]=%3d carry=%d C[%d] = %3d \n", i, A[i], i, B[i], carry, i, C[i]) ; carry = x / 256 ; // should use bit operations here } C[6] = carry ; printf (" C[6] = %3d \n", C[6]) ; }