Is Number Odd?


Closed Thread
Results 1 to 30 of 30

Thread: Is Number Odd?

Hybrid View

  1. #1
    Join Date
    May 2006
    Location
    Del Rio, TX, USA
    Posts
    343


    Did you find this post helpful? Yes | No

    Default

    OK, This is better. It has to do one final check after the FOR..NEXT loop.

    Code:
    TestNumber as word
    TestVal as word
    
    For TestVal = 65534 to 2 step -2
    	If (TestNumber + TestVal)= 0 Then
    		LCDOUT "Even"
    		EndProgram
    	Else
    		If (TestNumber + TestVal) + 1 = 0 then
    			LCDOUT "Odd"
    			EndProgram
    		Else
    	Endif
    Next TestVal
    If (TestNumber + TestVal) - 1 = 0 then
           LCDOUT "Odd"
           EndProgram
    Else
           LCDOUT "Zero"
    Endif
    EndProgram:
    end
    Last edited by SteveB; - 11th June 2008 at 17:35.

  2. #2
    T.Jackson's Avatar
    T.Jackson Guest


    Did you find this post helpful? Yes | No

    Default

    Recursive example ...

    Code:
    public int divideBy(int n)
    {
       num = num / n
       if(num > 0)
          divideBy(n);
    }
    It keeps calling itself until we have arrived at something. In PBP you would of course need to exchange the "public int divideBy(int n)" with a label and swap "divideBy(n)" with a goto.

    Trent Jackson

  3. #3
    Join Date
    Mar 2006
    Location
    INDIA
    Posts
    89


    Did you find this post helpful? Yes | No

    Default

    Hi Trent, I think...

    There'r Out of 10's methods. You want's onlyup to 10th.
    So should Listing now.

    .

Similar Threads

  1. Dynamic USB Serial Number (PIC18F4550)
    By awmt102 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 16th July 2009, 17:03
  2. dec number to show on lcd (maths)
    By savnik in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 28th August 2007, 19:18
  3. Working with the random number generator
    By kwelna in forum mel PIC BASIC
    Replies: 9
    Last Post: - 16th January 2007, 17:50
  4. Random number results
    By bartman in forum mel PIC BASIC
    Replies: 3
    Last Post: - 9th March 2005, 17:39
  5. more random number questions
    By bartman in forum mel PIC BASIC
    Replies: 1
    Last Post: - 14th November 2004, 17:55

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts