answersLogoWhite

0

int dividend,divisor,remainder;

int division(int p,int q){

int quotient=1;

/*if divisor and diviend are equal then quotient=1*/

if(p==q){

remainder=0;

return 1;

}

/*if dividend is smaller than divisor then remainder=dividend*/

if(p<q){

remainder=p;

return 0;

}

/*shift left till divisor > dividend*/

while(p>=q){

q<<=1;

quotient<<=1;

}

/*shift right for one time so that divisor become smaller than dividend*/

q>>=1;

quotient>>=1;

/*again call division recurcively*/

quotient+=division(p-q,divisor);

return quotient;

}

int main(){

cout<<"\nEnter dividend:";

cin>>dividend;

cout<<"\nEnter divisor:";

cin>>divisor;

cout<<"\nQuotient:"<<division(dividend,divisor);

cout<<"\nRemainder:"<<remainder;

//system("pause");

return 0;

}

User Avatar

Wiki User

13y ago

What else can I help you with?

Related Questions

How to divide to numbers in qbasic?

In QBasic, you can divide two numbers using the division operator /. For example, to divide the variable a by b, you would write result = a / b, where result stores the outcome of the division. Ensure that b is not zero to avoid a division by zero error. You can then use the PRINT statement to display the result, such as PRINT result.


Write a program to divide 2 numbers without using the division operator?

int divide1(int a,int b) { int t=1; while(b*t&lt;=a) { t++; } return t-1; }


What arithmetic operator directs Excel to perform the division operation?

the divide symbol (/)


Is Division closed in Real?

No, since you can't divide by zero. On the other hand, the set of real numbers without zero is closed under division.


What do you call it when you divide two numbers?

division.


What is the answer called when you divide two numbers?

The Answer To A Division Problem Is The Quotient.


What are friendly parts in division?

You break up the division problems into numbers that are easy to divide in your head.


What do you do when you are finding the prime factorization of a number and you are using the division method and there are no numbers to divide?

If there are no numbers to divide - not even 1 - then you have made a mistake.


How do you divide two digit numbers?

using the short or long division


Can there be leftovers in division?

Yes


How divide without a calculator?

Use the method of long division.


How do you do mixed number division?

You invert the second fraction then divide the whole numbers and there is your answer