首页 > 代码库 > Objective-C 程序设计(第六版)第二章习题答案

Objective-C 程序设计(第六版)第二章习题答案

 

1.略

2.

#import <Foundation/Foundation.h>int main(int argc, const char * argv[]){    @autoreleasepool {                // insert code here...       NSLog(@"In Obiective-c, lowercase letters are significance .\n main is where program execution begins.\n Open and closed brace enclose program stateme               nts in a routine .\n All program statements must be terminated by a semicolon .");

       }

    return 0;

  }

3.

    testing...

    .... 1

    ... 2

    .. 3

4. 

 int value1, value2, sum;        
value1
= 87; value2 = 15; sum = value1 - value2; NSLog(@"sum is %i", sum);

5.改正后的程序

  int sum;                               <---原文INT改为int.
/* COMPUTE RESULT*/ <---原文右注释号//改为*/. sum = 25+37-19; <---原文后加分号结束. /* DISPLAY RESULTS*/ <---原文注释号改为/*..*/或//. NSLog(@"The answer is %i",sum); <---原文改为双引号,加上sum前的逗号.

6.

  The result is 95.

 

 

END

Objective-C 程序设计(第六版)第二章习题答案