December 2013
Beginner
576 pages
16h 4m
English
Not only can simple phrases be displayed with NSLog, but the values of variables and the results of computations can be displayed as well. Program 2.4 uses the NSLog routine to display the results of adding two numbers, 50 and 25.
Program 2.4
#import <Foundation/Foundation.h>int main (int argc, const char *argv[]){ @autoreleasepool { int sum; sum = 50 + 25; NSLog (@"The sum of 50 and 25 is %i", sum); } return 0;}
Program 2.4 Output
The sum of 50 and 25 is 75
The first program statement inside main after the autorelease pool is set up defines the variable sum to be of type integer. You must define all program variables before you can use them in a program. ...
Read now
Unlock full access