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

12y ago

What else can I help you with?

Related Questions

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


WHAT OPERATOR FOR DIVISION IS USED WHEN WRITING A FORMULA?

In most programming languages and spreadsheet applications, the operator for division is represented by the forward slash symbol (/). For example, in a formula, you would write something like A1 / B1 to divide the value in cell A1 by the value in cell B1. In some languages, such as Python, this operator performs floating-point division, while others may have specific operators for integer division.