The first day of C in iOS

Source: Internet
Author: User

////main.m//Lessonbasic////Created by Laouhn on 15/7/14.//Copyright (c) 2015 David. All rights reserved.//#import<Foundation/Foundation.h>intMainintargcConst Char*argv[]) {    voidTest5 ();      Test5 (); return 0;}voidTest5 () {//console input A character, receive, and output    CharA ='a'; printf ("Please enter a character:"); scanf ("%c",&a); printf ("a=%c", a);}voidtest4 () {intA =4;  Shortb =5; Longc =6; floatE =7.00; Charf='a'; printf ("A =%d,b=%hd,c=%ld,e=%f,f=%c\n", a,b,c,e,f); printf ("%-4d,%d\n",1,2); printf ("%04d\n",1); printf ("Please enter an integer:"); scanf ("%d",&a); printf ("A =%d\n", a);}voidtest3 () {printf ("Hello,world!\n"); intA =3; intb =5; printf ("A + b =%d\na-b =%d\na * b =%d\na/b =%d\n a percent B =%d", A + b,a-b,a * b,a/b,a%b); }voidtest2 () {intA =4; intb =5; intc =b; b=A; A=C; printf ("A =%d,b =%d", A, b); intA1 = A; intA2 = the; A1=a2+A1; A2=a1-A2; A1=a1-A2; printf ("A1 =%d,a2 =%d", A1,A2);}voidtest1 () {//there are two forms of the import header file: <>, ""//<> role: Importing system files//"Role: Import files that others have written. "//data type: function, type of data specified, and size//' 0 '-----' 9 ' corresponds to----//' A '---' B ' corresponds to----//' a '----' Z ' corresponds to the----122//' A ' +32= ' a '    /*     1. Basic data type: shaping, floating-point shaping: Long 32-bit system in 4 bytes, 64-bit system in 8 bytes, int 4 bytes short 2 bytes Char 1-byte float: single-precision floating-point float 4-byte double-precision floating-point type Double 8-byte 2. Constant: Not subject to external forces, the volume is not changed     Form constants: 9527,22,56 floating-point constants: 3.1415926-character constants: ' 9 ', ' 1 ', ' A ', ' m ' 3. Variable definition: Data type variable name = initial value;     int age = 27;//variable definition, be sure to brush the bowl (assign initial value) Char age= ' a ';     float age=2.3;     Double age=2.33; 4. Variable name naming rules: 1. Consists of numbers, letters, underscores, and numbers cannot begin with 2. Cannot be duplicate with System keyword 3. Cannot be associated with another variable name 4. See the name of the meaning 5. Operator assignment operator: "=", the equal sign The value on the right, the process of assigning a value to the left of the equals sign, the process of the city copy, the value to the right of the equal sign, a copy of the value arithmetic operator assigned to the left of the equals sign: +,-, *,/,++,--6. Expression: can be composed of constants, variables, operators how to sentence     Break is not an expression: there is no value!     int a = 3;     int b = 5;     A + 3;     A + b;     Statement: With a semicolon ";", at the end of 7. Format the output function int a = 3;     int b = 5;     printf ("A + b =%sd\na-b =%d\na * b =%d\na/b =%d\n a percent B =%d", A + b,a-b,a * b,a/b,a% B);  The purpose of the formatted output is to verify the 7.1 conversion:%d----int%HD--Short%ld--  Long%f--float,double%c----Char 7.2 escape character: percent//printf ("%-4d, %d\n ","///left-aligned printf ("%04d\n", 1);//right-aligned 8. Format Input function console input an integer, and receive first, define a variable, what type of variable? With the input type       The same variable int a = 0;      scanf ();*/    //use after initialization of variables    CharAge ='a'; floatAge1 =2.3; DoubleAge2 =2.33; NSLog (@"%f", age2+ (Double)2); Age='1'; Age1=4.2; Age2=23.33;//int a =3;//int b = 4;//int sum = a + b;//int sub =a-b;//int mul = a * b;//int divi = A/b;//int rem = a% B;//printf ("divi =%d,rem =%d", divi,rem);//Note that the number of ends of the remainder must be an integer variable            intA =3; intb =5; A++;//equivalent to A = a + 1;++A; //compound operator: +=,-=,*=,/=,%=A + = B;//equivalence with a = a + B;B + =A; A-=b; b-=A; A*= b;//equivalent to a = a * b;a/= b;//equivalent to A = A/b;a%= b;//equivalent to a= a% B; //A + 0;    }

The first day of C in iOS

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.