I don't know u will be happy with this or not but let me explain in
simplest way
PS: i haven't used division operator anywhere but i also i haven't
done using Bit Logic  which is efficient then this one but below code
work & simplest way to understand


This One is the Simply Logical. This will work all kind of Inputs. The
concept behind this is We need to Perform the Reverse Operation
performed on the Mutiplication Without '*' Opreator. Here we need to
Subtract the Second Number From the First Number Until First Number >=
Second Number. That’s All.

For example, Assume that a=10, b=3. Here we need to do is Subtract the
Number 3 from the number 10 itself, until a>=b. And we should make a
count for how many times we are doing like this, It is the Quotient
Value.

So, finally We get the Answer as 3 Times we subtract 3 from the Number
10. Because we are checking the Condition a>=b everytime. So the is
the Quotient as 3. The Remainder will be stored itself in 'a' as 1.




#include
#include

void main()
{
int a,b,c;
clrscr();

printf("Enter 2 No.s :\n");
scanf("%d%d",&a,&b); // Read 2 Numbers

if(b==0) // Here we are Checking for the Divide By Zero Error
{
printf("\nDivide By Zero Error");
}

else
{
c=0; // Here c as Count, and we should initialize the Count value to
0.
while(a>=b) // We Repeatedly Checking for the Condition a>=b
{
a = a - b; // Subtract b from a, and the new result stored in 'a'
itself
c++; // Incrementing the Count
}

printf("\nQuotient = %d \n Remainder = %d",c,a); // Print Quotient and
Remainder
}

getch();
}


Thanks
Shashank>>"The Best Way To Escape From The Problem  is to Solve It"
CSE,BIT Mesra

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to