3 Replies - 5114 Views - Last Post: 07 May 2009 - 10:32 AM Rate Topic: -----

#1 chaitrahosmane  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 07-May 09

Program to divide a number without using / % * in C

Post icon  Posted 07 May 2009 - 09:50 AM

Program to divide a number without using / % * in C.
Please tell me what is the logic for this.?
Is This A Good Question/Topic? 0
  • +

Replies To: Program to divide a number without using / % * in C

#2 Jubb  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 88
  • Joined: 06-May 09

Re: Program to divide a number without using / % * in C

Posted 07 May 2009 - 09:51 AM

Sounds like you want to do some bit shifting. Look it up. Maybe you could get away with putting some inline asm in there, you wouldn't *technically* be using / % or *. :D
Was This Post Helpful? 0
  • +
  • -

#3 chaitrahosmane  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 07-May 09

Re: Program to divide a number without using / % * in C

Posted 07 May 2009 - 09:55 AM

View PostJubb, on 7 May, 2009 - 08:51 AM, said:

Sounds like you want to do some bit shifting. Look it up. Maybe you could get away with putting some inline asm in there, you wouldn't *technically* be using / % or *. :D



Yes i can do bit shifting. But bit shifting can multiply and divide only by 2.?
If i want to divide by 3 (i forgot to mention in the question) what i need to do..?
Was This Post Helpful? 0
  • +
  • -

#4 baavgai  Icon User is offline

  • Dreaming Coder
  • member icon

Reputation: 5848
  • View blog
  • Posts: 12,707
  • Joined: 16-October 07

Re: Program to divide a number without using / % * in C

Posted 07 May 2009 - 10:32 AM

View Postchaitrahosmane, on 7 May, 2009 - 10:55 AM, said:

If i want to divide by 3 (i forgot to mention in the question) what i need to do..?


When I was little kid, instead of saying 10 divided by 3, we'd say 3 "goes into" 10. Division is nothing more than subtracting one number from another until you can't. It should be obvious if you think about it. The only tricky part is dealing the remainder.

Good luck.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1