Answer to Question #183401 in C++ for Pervaiz

Question #183401

Building on previous assignment, make new functions Multiply and Divide in class BaraBitkaar i.e.

BaraBitKaar Multiply(BaraBitKaar b);

void Divide(BaraBitKaar b, BaraBitKaar & quotient, BaraBitKaar & remainder); //Notice that quotient and remainder are returned through parameters (pass by reference).


1
Expert's answer
2021-04-20T16:20:51-0400
#include<iostream>
using namespace std;

class BaraBitKaar{

public:
    BaraBitKaar(){

    }
void sub(int a, int b){
int sub=0;
sub=a-b;
cout<<" sum of the given binary number be:"<<sub<<endl;
}
 void mul(int a, int b){
int mul;
mul=a*b;
cout<<"multiplication of the given binary number be:"<<mul<<endl;

 }

 void div(int a, int b){
int div=0;
div=a/b;
cout<<"the division of the given binary number be:"<<div<<endl;

 }
};

int main(){
BaraBitKaar bar;
char c,d;
//first input
cout<<"please enter input 1"<<endl;
uint32_t a = 0;

  while ((c=getchar()) != '\n') {
    a <<= 1;
    a += (c - '0') & 1;
  }
printf("%u\n", a);
//second input
cout<<"please enter input 2"<<endl;
uint32_t e = 0;

  while ((d=getchar()) != '\n') {
    e <<= 1;
    e += (d - '0') & 1;
  }
printf("%u\n", e);

bar.sub(a,e);
bar.div(a,e);
bar.mul(a,e);


return 0;
 }

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS