Interview Questions and Answers :: Cisco
Home > Experience Archives > Cisco > Interview Question Set 3 > Discussion
4. Write a Program to swap the 2 nibbles of a byte size variable.
Answer:
assuming 2 numbers are
a = 10
b = 20
 # 1. Summing up two numbers and store in 'a'
a = a bÂ
# 2. swap b by subtracting b value from above a value
b = a - b # b = 30 - 20 = 10
# 3. get a value swappedÂ
a = a - b # a = 30 - 10 = 20
Â
Shreeshail Gumgeri
8 Apr, 2018 5:00 PM
assuming 2 numbers are
a = 10
b = 20
 # 1. Summing up two numbers and store in 'a'
a = a bÂ
# 2. swap b by subtracting b value from above a value
b = a - b # b = 30 - 20 = 10
# 3. get a value swappedÂ
a = a - b # a = 30 - 10 = 20
Â
Report Error
Report Error
Please Login First Click Here