Re: [algogeeks] Re: Divide 2 nos. without DIVISON

2011-05-23 Thread Aakash Johari
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;

Re: [algogeeks] Re: Divide 2 nos. without DIVISON

2011-05-22 Thread ankit sambyal
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

Re: [algogeeks] Re: Divide 2 nos. without DIVISON

2011-05-22 Thread Puneet Ginoria
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

Re: [algogeeks] Re: Divide 2 nos. without DIVISON

2011-05-22 Thread Prakash D IT @ CEG
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

Re: [algogeeks] Re: Divide 2 nos. without DIVISON

2011-05-22 Thread Wladimir Tavares
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

Re: [algogeeks] Re: Divide 2 nos. without DIVISON

2011-05-22 Thread Aakash Johari
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);

Re: [algogeeks] Re: Divide 2 nos. without DIVISON

2011-05-22 Thread Aakash Johari
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;