• 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
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]

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


  • Subject: Newbie needs help with an exercise from the Book Programming in Objective-C 2.0
  • From: James Carroll <email@hidden>
  • Date: Mon, 2 Mar 2009 17:56:28 +0000

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;

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

  • Follow-Ups:
    • Re: Newbie needs help with an exercise from the Book Programming in Objective-C 2.0
      • From: Tommy Nordgren <email@hidden>
    • Re: Newbie needs help with an exercise from the Book Programming in Objective-C 2.0
      • From: Alexander von Below <email@hidden>
  • Prev by Date: Re: 10.4u sdk to 10.5 sdk OpenTransport.h file inclusion problem
  • Next by Date: Re: variable viewing in gdb window
  • Previous by thread: pytGenStrings script
  • Next by thread: Re: Newbie needs help with an exercise from the Book Programming in Objective-C 2.0
  • Index(es):
    • Date
    • Thread