C Puzzle-2

value = a? b: c

Write the code which implements the same logic without using conditional statements?


Answer:

value = (!!a)*b+(1-!!a)*c

Comments

Popular posts from this blog

Appending and Prepending in Yocto - +=, =+ vs .=, =.

Connecting Serial ports of two Ubuntu VMWare Virtual Machines

Linux Commands for Hardware Info - lshw, lspci, lsdev, lscpu, lsblk, lsusb