A modification in the above code,
int divide(int a, int b)
{
int temp = 0;
int result = 0;
int mask, i;
printf (a = %d, b = %d\n, a, b);
temp = 0;
for ( i = 30; i = 0; i-- ) {
mask = 1 i;
temp = 1;
Solve it using shift operator here is the crude algo :
the procedure for the division algorithm, given a dividend and a divisor
would be to left shift (multiply by 2) the divisor till it reaches
dividend/2, then continue this routine with the the difference between the
dividend and divisor
thnxx all.. i got the soln..
Qdumanshu: i was asking for quotient and remainder when we divide 2 nos.
without actually dividing them...
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
could someone explain the algo with an example?
On Sun, May 22, 2011 at 8:21 PM, Puneet Ginoria punnu.gino...@gmail.comwrote:
thnxx all.. i got the soln..
Qdumanshu: i was asking for quotient and remainder when we divide 2 nos.
without actually dividing them...
--
You received this
a divide b
while(b!=1){
a =1;
b =1;
}
printf(%d\n,a);
Wladimir Araujo Tavares
*Federal University of CearĂ¡
*
On Sun, May 22, 2011 at 1:33 PM, Prakash D IT @ CEG cegprak...@gmail.comwrote:
could someone explain the algo with an example?
On Sun, May 22, 2011 at 8:21 PM, Puneet
try for 15 and 3
On Sun, May 22, 2011 at 10:22 PM, D.N.Vishwakarma@IITR deok...@gmail.comwrote:
a divide b
while(b!=1){
a =1;
b =1;
}
printf(%d\n,a);
On 5/22/11, Wladimir Tavares wladimir...@gmail.com wrote:
a divide b
while(b!=1){
a =1;
b =1;
}
printf(%d\n,a);
Try the following code: One can more optimize it.
int divide(int a, int b)
{
int temp = 0;
int result = 0;
int mask, i;
printf (a = %d, b = %d\n, a, b);
temp = 0;
for ( i = 30; i = 0; i-- ) {
mask = 1 i;