Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a function with header [b] = myBinAdder (b_1, b_2), where b_1, b_2, and b

ID: 3828934 • Letter: W

Question

Write a function with header [b] = myBinAdder (b_1, b_2), where b_1, b_2, and b are binary numbers represented as in problem 1. The output variable should be computed as b = b_1 + b)_2. Do not use your functions from problems 1 and 2 to write the function (i.e., do not convert b_1 and b_2 to decimal: add them, and then convert the result back to binary). This function should be able to accept inputs b_1 and b_2 of any length (i.e., very long binary numbers), and b_1 and b_2 may not necessarily be the same length. Test Cases: >> b = myBinAdder ([1 1 1 1 1], [1]) b = 1 0 0 0 0 0 >> b += myBinAdder ([1 1 1 1 1], [1 0 1 0 1 0 0 1] b = >> b = myBinAdder ([1 1 0], [1, 0 1])

Explanation / Answer

#include<iostream.h>

void main()

{

unsigned long long int a[5],b[5],i,result;

for (i=0;i<=5;i++)

{

cin>>a[i]>>b[i];

if(a[i]==1&&b[i]==1)

{

result=1;

else if(a[i]==1&&b[i]==0)//(a[i]==0&&b[i]==1)//(a[i]==0&&b[i]==0)

result=0;

}

cout<<result;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote