以下程序通过使用算术运算符,计算8*2-9/10*20。程序代码如下:
2015-01-18 11:08:22.514 Sample.3.4[1021:65109] Hello, This is a sample 3.4 of the book 《iOS7 开发快速入门》!
2015-01-18 11:08:22.516 Sample.3.4[1021:65109] 16.000000
Program ended with exit code: 0
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]) {
@autoreleasepool {
// insert code here...
NSLog(@"Hello, This is a sample 3.4 of the book 《iOS7 开发快速入门》!");
float a;
a = 8*2-9/10*20;
NSLog(@"%f",a);
}
return 0;
}
运行结果如下:
2015-01-18 11:08:22.514 Sample.3.4[1021:65109] Hello, This is a sample 3.4 of the book 《iOS7 开发快速入门》!
2015-01-18 11:08:22.516 Sample.3.4[1021:65109] 16.000000
Program ended with exit code: 0