a and b must be bits....i.e 0 and/or 1
void halfadder(int a, int b)
{
carry=a*b
sum=a * ~b + b * ~a // or use a ^ b
}
void fulladder(int a, int b ,int carryin)
{
carryout=a * b+b * carryin+ a * carryin
sum= a ^ b ^ c
// you can convert into sop form
}