arithmatic operations without using them..

This is a discussion on arithmatic operations without using them.. within the C++ Programming forums, part of the General Programming Boards category; Hi. I was reading a magzine. It had this question Without using /,% and * operators. write a function to ...

  1. #1
    Registered User
    Join Date
    Apr 2007
    Location
    India
    Posts
    14

    arithmatic operations without using them..

    Hi.

    I was reading a magzine.

    It had this question

    Without using /,% and * operators. write a function to divide a number by 3.

    Can anyone help...

  2. #2
    Registered User
    Join Date
    Jun 2005
    Posts
    6,163
    Strikes me as a homework problem. Ever heard of logarithms?

  3. #3
    Math wizard
    Join Date
    Dec 2006
    Location
    USA
    Posts
    582
    Division is really repeated subtraction. Just take a base number, such as 8152 and subtract 3 from it, but add 1 to the count. When the number to subtract is less than the amount to be subtracted, stop. You have the answer and the remainder, if any. Just adding and subtracting is used.
    High elevation is the best elevation. The higher, the better the view!
    My computer: XP Pro SP3, 3.4 GHz i7-2600K CPU (OC'd to 4 GHz), 4 GB DDR3 RAM, X-Fi Platinum sound, GeForce 460, 1920x1440 resolution, 1250 GB HDD space, Visual C++ 2008 Express

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,418
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  5. #5
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,310
    Threads merged with duplicate deleted.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  6. #6
    Registered User
    Join Date
    Sep 2006
    Posts
    835
    Looks like an Adobe test from last year.

    http://www.google.com/search?q=%22wr...hl=en&filter=0

  7. #7
    Registered User
    Join Date
    Apr 2007
    Location
    India
    Posts
    14

    Thanks....

    THanks

  8. #8
    Registered User
    Join Date
    Apr 2007
    Location
    India
    Posts
    14

    Yes...it is from Adobe test paper...

    Quote Originally Posted by robatino View Post
    Looks like an Adobe test from last year.

    http://www.google.com/search?q=%22wr...hl=en&filter=0
    Yes...it is from Adobe test paper...

  9. #9
    Registered User
    Join Date
    Sep 2001
    Posts
    752
    Quote Originally Posted by ulillillia View Post
    Division is really repeated subtraction. Just take a base number, such as 8152 and subtract 3 from it, but add 1 to the count. When the number to subtract is less than the amount to be subtracted, stop. You have the answer and the remainder, if any. Just adding and subtracting is used.
    Presumably efficiency is part of the answer too. There is a logarithmic complexity solution to this problem
    Callou collei we'll code the way
    Of prime numbers and pings!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. doing floating operations using integer operations
    By ammalik in forum C Programming
    Replies: 10
    Last Post: 08-15-2006, 04:30 AM
  2. ROW OPERATIONS (finding Inverse) (im going crazy)
    By alexpos in forum C Programming
    Replies: 1
    Last Post: 11-20-2005, 09:07 AM
  3. Matrix and vector operations on computers
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 11
    Last Post: 05-11-2004, 06:36 AM
  4. String Class Operations
    By Aidman in forum C++ Programming
    Replies: 10
    Last Post: 04-06-2003, 02:29 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21