Skip to content

Instantly share code, notes, and snippets.

@gunavaran
Created October 15, 2020 15:56
Show Gist options
  • Save gunavaran/827c171abfee81596fe7ac2d50f2d3be to your computer and use it in GitHub Desktop.
Save gunavaran/827c171abfee81596fe7ac2d50f2d3be to your computer and use it in GitHub Desktop.
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