The code you provided is already buggy:
ar
and
arr
are not initialised to zero.
One way to correct it is:
for(i=0; i < 4, i++)
{
ar[i]=n%2;
n=n/2;
}
This code will fill
ar
and zero it at the same time.
What have you done about the bits adder ?
By the way we don't do your homework for you, we just help if you have a problem in the work you have done.