Thread: This should be fairly simple to fix.

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Mar 2004
    Posts
    12
    Hi,

    I think your powerfunc is totally wrong. I suppose you want to do some 2^4 = 2 * 2 * 2 * 2.

    So you should be doing

    Code:
    ULONG powerFunc(USHORT num, USHORT pow)
    {
         if (pow < 1) return 1;
         else return num * powerFunc(num, --pow);
    }
    Edit : By the way in your original code num will always be 2 and orignum will always be 2 so num = num *orignum will always be 2 * 2 = 4.
    Last edited by gautamn; 03-04-2004 at 05:58 AM.
    Life is a piece of chocolates

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help in a fairly simple C prog
    By CodeSlow in forum C Programming
    Replies: 4
    Last Post: 01-04-2008, 02:49 AM
  2. Simple Socialising Chat Bots
    By bengreenwood in forum C++ Programming
    Replies: 10
    Last Post: 11-28-2007, 08:42 AM
  3. Simple CPP (i think)
    By Smoose777 in forum C++ Programming
    Replies: 3
    Last Post: 02-27-2002, 12:34 AM
  4. The following code has one simple error.....
    By bluehead in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 11-08-2001, 07:45 PM
  5. One simple error(IN DOS)
    By bluehead in forum C++ Programming
    Replies: 10
    Last Post: 11-07-2001, 08:43 PM