Start learning with a piece of code
//// main.m// Demo1//// Created by lee on 14/10/27.// Copyright (c) 2014年 lee. All rights reserved.//#import <Foundation/Foundation.h>int main(int argc, const char * argv[]) { @autoreleasepool { int quotient, numertor, denominator; numertor = 10; denominator = 2; quotient = numertor/denominator; NSLog(@"The fraction is %i/%i \nthe quotient is %i", numertor, denominator, quotient); } return 0;}
1. Int quotient, numertor, denominator;
Defines Integer Variables. Common Data Types in object-C are as follows:
1.1 integer int integertype = 1;
1.2 float floattype = 3.14;
1.3Double Floating PointDouble doubletype = 3.1415;
1.4 short integer short int partition type = 50;
1.5 long integerLong long int longlongtype = 123456789l;
2.Quotient = numertor/denominator;
division of variables (> numertor/denominator) and then assign the obtained value to the supplier ( quotient)
3.Nslog (@ "the fraction is % I/% I \ nthe quotient is % I", numertor, denominator, quotient );
The usage of % I in nslog is the same as that in C language, that is, as long as the % I character is found in the nslog routine, it will be automatically replaced with the corresponding variable in the routine. \ N is a line break.
The program running result is as follows:
2014-10-27 21:30:48.556 Demo1[1521:67965] The fraction is 10/2 the quotient is 5Program ended with exit code: 0
Learning Object-C from scratch --- the next day