Amazon.com Widgets 13-1 Simple way
Welcome, Guest. Please login or register.
Did you miss your activation email?
June 19, 2013, 08:37:27 AM
Home Help Search chat Login Register   
News: Read this please.The Great Kangaroo Escape Looking for reviews of the 4th ed on Amazon!   Twitter:  @skochan
                     

+  Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
|-+  Old Stuff
| |-+  Answers to Exercises
| | |-+  Chapter 13
| | | |-+  13-1 Simple way
Pages: [1]   Go Down
Print
Author Topic: 13-1 Simple way  (Read 774 times)
tadej5553
Full Member
***
Posts: 145


Email




« on: May 21, 2010, 11:43:03 AM »

main.m
Code: (Objective-C)
#import <Foundation/Foundation.h> 
   
float array_average(float *f)
{
    float sum;
    int i = 10;
   
    while(i--)
        sum += *f++;
       
    return sum/10;
}

int main (int argc, char *argv[])
{
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   
    float array[] = {2,1,2,3,4,5,6,7,8,9};
   
    NSLog(@"the average is: %f", array_average(array));
       
    [pool drain];
    return 0;
}
Logged
Pages: [1]   Go Up
Print
Jump to:  



Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Entire forum contents (c) 2009 classroomM.com. All rights reserved.