December 2013
Beginner
576 pages
16h 4m
English
Program 4.3 reinforces what we have just discussed and introduces the concept of integer arithmetic.
Program 4.3
// More arithmetic expressions#import <Foundation/Foundation.h>int main (int argc, char * argv[]){ @autoreleasepool { int a = 25; int b = 2; float c = 25.0; float d = 2.0; NSLog (@"6 + a / 5 * b = %i", 6 + a / 5 * b); NSLog (@"a / b * b = %i", a / b * b); NSLog (@"c / d * d = %f", c / d * d); NSLog (@"-a = %i", -a); } return 0;}
Program 4.3 Output
6 + a / 5 * b = 16a / b * b = 24c / d * d = 25.000000-a = -25
We inserted extra blank spaces between int and the declaration of a, b, and result in the first ...
Read now
Unlock full access