help with homework

This is a discussion on help with homework within the C Programming forums, part of the General Programming Boards category; Im having problems with a few questions 1)What will this algorithm print for j = 1 to 12 do num[j]=j ...

  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
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,657

  3. #3
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    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, 05:49 PM
  3. Homework
    By kermi3 in forum C++ Programming
    Replies: 15
    Last Post: 09-26-2001, 04:16 PM
  4. Homework
    By kermi3 in forum Windows Programming
    Replies: 5
    Last Post: 09-15-2001, 12:48 PM
  5. Homework
    By kermi3 in forum C Programming
    Replies: 0
    Last Post: 09-10-2001, 02:26 PM

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