22. Carry Flag in 8-bit Addition

You are given two uint8_t numbers — a and b. You have to add them and store in 8-bit variable only. As addition may overflow (>255), you have to 

  • Output the sum as it would appear in an 8-bit register (wrapped)
  • Output the carry flag (1 if carry occurred, 0 otherwise)

Note: You can use only 8-bit variables. No uint16_t, no casting to larger types.

 

Example-1

Input:  a = 255, b = 1
Output: sum = 0, carry = 1


Example-2

Input:  a = 200, b = 100  
Output: sum = 44, carry = 1

 

 

Loading...

Input

100 50

Expected Output

150 0