• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Newbie needs help with an exercise from the Book Programming in Objective-C 2.0
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Newbie needs help with an exercise from the Book Programming in Objective-C 2.0


  • Subject: Re: Newbie needs help with an exercise from the Book Programming in Objective-C 2.0
  • From: Tommy Nordgren <email@hidden>
  • Date: Tue, 3 Mar 2009 03:00:13 +0100


On Mar 2, 2009, at 6:56 PM, James Carroll wrote:

Hi there,
I hope this is the right way to go about getting help! I am methodically going through the book Programming in Objective-C 2.0 and have hit an exercise (for anyone who has it, page 96 Exercise 2) I'm stuck on. Now I am going to go back over this chapter anyway as there are clearly a few things I need to go back through, but was wondering if anyone can help tell me what I am doing wrong with this code so at least I can see what I did wrong and don't compound the mistake as I have written it a few ways and can't make it work!


I am looking for every fifth triangular numbers (5,10,15 etc to 50) using this formula;
triangleNumber = n (n + 1) / 2


For example to find the 10th triangle number you swap n for 10.

The bit that seems to be getting me stuck is the actual formula, no matter what I do the error comes up "n is not a function", could someone show me what I'm doing wrong?Here is my last attempt at the bit of code!




#import <Foundation/Foundation.h>


int main (int argc, const char * argv[]) {

NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

int n, number, triangleNumber;


// insert code here...

NSLog(@"triangle numbers 5 to 55");


triangleNumber = 0;


do {

triangleNumber = n (n + 1) / 2;


Only Symbolic Math Programs like Mathematica allows multiplication without an explicit multiplication operator


triangleNumber = n * (n +1) / 2;
NSLog(@"i% i%", number, triangleNumber);

number = n+5;

}

while ( number <=50);


[pool drain];

return 0;

}


Thanks in advcnace.



James Carroll Director
evil.twin.artworks
email@hidden
http://www.eviltwinartworks.com




_______________________________________________ Do not post admin requests to the list. They will be ignored. Xcode-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden

------------------------------------------------------ "Home is not where you are born, but where your heart finds peace" - Tommy Nordgren, "The dying old crone" email@hidden


_______________________________________________ Do not post admin requests to the list. They will be ignored. Xcode-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Newbie needs help with an exercise from the Book Programming in Objective-C 2.0 (From: James Carroll <email@hidden>)

  • Prev by Date: Re: memory leaks and C++
  • Next by Date: Re: Subversion doesn't appear to see class files in Xcode
  • Previous by thread: Re: Newbie needs help with an exercise from the Book Programming in Objective-C 2.0
  • Next by thread: memory leaks and C++
  • Index(es):
    • Date
    • Thread