Thread: help with homework

  1. #1
    Registered User
    Join Date
    Nov 2009
    Posts
    4

    help with homework

    Im having problems with a few questions

    1)What will this algorithm print
    for j = 1 to 12 do
    num[j]=j
    end for

    k=0
    for j=5 to 7 do
    k=k+j
    num[k-j+1]=j+k
    end for

    for j=1 to 7 do
    print 'num',j,'is',num[j]
    end for

    2)does this recursive module return when it is called with n=5
    module mystery (n:integer)
    if(n>0) then
    return n + mystery(n-1)
    else
    return 0;
    end module

  2. #2

  3. #3
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    Im having problems with a few questions
    What problems, exactly? We're happy to help if you can tell us what you don't understand or why you're having trouble. Simply not knowing the answer is not a valid problem.

  4. #4
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    The algorithm won't print anything, because algorithms really prefer cursive writing.

    Seriously, it's weird that you're asking these questions, when you can just code them up, and find out for sure, and in less time.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Homework
    By kermi3 in forum A Brief History of Cprogramming.com
    Replies: 11
    Last Post: 11-03-2001, 04:39 PM
  2. Homework
    By kermi3 in forum C Programming
    Replies: 10
    Last Post: 09-27-2001, 04:49 PM
  3. Homework
    By kermi3 in forum C++ Programming
    Replies: 15
    Last Post: 09-26-2001, 03:16 PM
  4. Homework
    By kermi3 in forum Windows Programming
    Replies: 5
    Last Post: 09-15-2001, 11:48 AM
  5. Homework
    By kermi3 in forum C Programming
    Replies: 0
    Last Post: 09-10-2001, 01:26 PM