Created
October 15, 2020 15:56
-
-
Save gunavaran/827c171abfee81596fe7ac2d50f2d3be to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void full_adder(int a, int b, int c, int *sum, int *carry) { | |
if (a == 0) { | |
if (b == 0) { | |
if (c == 0) { | |
*carry = 0; | |
*sum = 0; | |
} else { | |
*carry = 0; | |
*sum = 1; | |
} | |
} else { | |
if (c == 0) { | |
*carry = 0; | |
*sum = 1; | |
} else { | |
*carry = 1; | |
*sum = 0; | |
} | |
} | |
} else { | |
if (b == 0) { | |
if (c == 0) { | |
*carry = 0; | |
*sum = 1; | |
} else { | |
*carry = 1; | |
*sum = 0; | |
} | |
} else { | |
if (c == 0) { | |
*carry = 1; | |
*sum = 0; | |
} else { | |
*carry = 1; | |
*sum = 1; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment