hey everybody!
i wnat to write a c++ code that manipulates a binary addition.
here is what i made:
for(i=1;i<=n;i++)
{
d=(a+[bi])/2;
if(a==1)
c=0;
else
c=1;
}
// a and b are arrays of size n and c is the sum in binary form.
but the problem arises how to transfer the carry to the next.
i have tried some what like this:
if(a==1&&b==1)
c[i+1]=c[i+1]+1;
i am not that much sure whether it is correct or not.
but even in this there is a problem of how to call back the above code.
(i am not saying that a problem of calling a function).
can u help u friends?
i wnat to write a c++ code that manipulates a binary addition.
here is what i made:
for(i=1;i<=n;i++)
{
d=(a+[bi])/2;
if(a==1)
c=0;
else
c=1;
}
// a and b are arrays of size n and c is the sum in binary form.
but the problem arises how to transfer the carry to the next.
i have tried some what like this:
if(a==1&&b==1)
c[i+1]=c[i+1]+1;
i am not that much sure whether it is correct or not.
but even in this there is a problem of how to call back the above code.
(i am not saying that a problem of calling a function).
can u help u friends?