top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

how to write a program for half adder in C++?

+2 votes
1,353 views
how to write a program for half adder in C++?
posted Apr 7, 2014 by Simranjeet Singh

Share this question
Facebook Share Button Twitter Share Button Google+ Share Button LinkedIn Share Button Multiple Social Share Button

1 Answer

+1 vote

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 
}
answer Apr 7, 2014 by Prakash
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...