iOS Learning C language Day01
Last Update:2016-03-07
Source: Internet
Author: User
<span id="Label3"></p><p><p><span style="font-size: 18pt;"><strong><span style="font-size: 18pt;"><strong>Comments</strong></span></strong></span></p></p><p><p><span style="font-size: 18px;">Single-line Comment<br>Annotations serve as explanations to the code, and annotations are for programmers to see<br>, do not participate in the program run<br><br>/*<br>Multi-line comments<br>Xcode shortcut keys<br>Select All Cmd+a<br>Copy Cmd+c<br>Paste Cmd+v<br>Set cmd+,<br>Comment cmd+/<br>Run Cmd+r<br>Compiling cmd+b<br>*/</span></p></p><p><p><span style="font-size: 18pt;"><strong>In-process Conversion</strong></span></p></p><p><p><span style="font-size: 18px;">-binary->n-in-process to remove the reverse redundancy</span></p></p><p><p><span style="font-size: 18px;">N-decimal Sum by weights</span></p></p><p><p><span style="font-size: 18px;">n binary->n Hexadecimal bit = four-bit bits<br></span></p></p><p><p><span style="font-size: 18pt;"><strong>Data type</strong></span></p></p><p><p><span style="font-size: 18px;">Integral type: short 2 bytes<br>int 4 bytes (common)<br>A long 4 or 8 bytes<br>A long long 8 bytes</span></p></p><p><p><span style="font-size: 18px;">Float type: Float Single precision type 4 bytes<br>Double multi-precision type 8 bytes</span></p></p><p><p><span style="font-size: 18px;">Character type: Char 1 bytes</span></p></p><span style="font-size: 18px;"><span style="font-size:18px;"><span style="font-family: ' Pingfang SC ';"><span style="color: #1d9421;"><span style="font:18.0px Menlo; font-variant-ligatures:no-common-ligatures; Color: #1d9421; "> Float<span style="font:18.0px ' Pingfang SC '; font-variant-ligatures:no-common-ligatures; color: #1d9421;"> and <span style="font:18.0px Menlo; font-variant-ligatures:no-common-ligatures; color: #1d9421;">double<span style="font:18.0px ' Pingfang SC '; font-variant-ligatures:no-common-ligatures; Color: #1d9421; "> The difference: accuracy is not the Same. </span></span></span></span></span></span></span></span><span style="font-size: 18px;"><span style="font-size:18px;"><span style="font-family:menlo;"><span style="color: #1d9421;"> FLOAT <span style="font:18.0px Menlo; font-variant-ligatures:no-common-ligatures; Color: #1d9421; " the number of significant digits is span>6<span style="font:18.0px ' Pingfang SC '; font-variant-ligatures:no-common-ligatures; color: #1d9421;"> bit. </span></span></span></span></span></span><span style="font-size: 18px;"><span style="font-size:18px;"><span style="font-family: ' Pingfang SC ';"><span style="color: #1d9421;"><span style="font:18.0px Menlo; font-variant-ligatures:no-common-ligatures; Color: #1d9421; "> double<span style="font:18.0px ' Pingfang SC '; font-variant-ligatures:no-common-ligatures; Color: #1d9421; "> The effective digits are <span style="font:18.0px Menlo; font-variant-ligatures:no-common-ligatures; color: #1d9421;">15<span style="font:18.0px ' Pingfang SC '; font-variant-ligatures:no-common-ligatures; Color: #1d9421; "> > Bit. </span></span></span></span></span></span></span></span><span style="font-size: 18px;"><span style="font-size: 18px;"><span style="font-family: Menlo;"><span style="color: #1d9421;">• Number of <span style="font: 18.0px ‘PingFang SC‘; font-variant-ligatures: no-common-ligatures; color: #1d9421;">significant digits: from the number on the left, which is not <span style="font: 18.0px Menlo; font-variant-ligatures: no-common-ligatures; color: #1d9421;">0 <span style="font: 18.0px ‘PingFang SC‘; font-variant-ligatures: no-common-ligatures; color: #1d9421;">, to the exact number of stops, all Numbers. </span></span></span></span></span></span></span><p><p><span style="font-size: 18pt;"><strong>constants, variables</strong></span></p></p><p><p><span style="font-size: 18px;"> <strong>Constants</strong> : The amount of time that a program cannot be changed while it is running</span></p></p><p><p><span style="font-size: 18px;">/*<br>Integer constant 10,-100<br>Floating-point constants: 20.3, 3.5<br>Character-type constants: ' A ', ' F ', ' ', ' 1 '<br>*/</span></p></p><p><p><span style="font-size: 18px;"> <strong></strong> variables: variables can be modified during the program run, variables are a storage area, the contents of the store can be changed<br> <strong>Definition of a variable</strong><br>Type modifier variable name = initial value;<br>=: assignment operator, which assigns a value of 18 to the age</span></p></p><p><p><span style="font-size: 18px;">int age = 18;</span></p></p><p><p><span style="font-size: 18px;"> <strong>Variable name naming rules</strong></span></p></p><p><p><span style="font-size: 18px;">1. can only be composed of letters, numbers, underscores, $, cannot start with a number</span></p></p><p><p><span style="font-size: 18px;">2. cannot have the same name as the system reserved word</span></p></p><p><p><span style="font-size: 18px;">3. Variable name names cannot be duplicated</span></p></p><p><p><span style="font-size: 18px;">4. See the meaning of the name (specification)</span></p></p><p><p><span style="font-size: 18px;">5. Hump Nomenclature (in The case of multiple words, the first letter is lowercase, starting with the second word, capitalized in the first letter)</span></p></p><p><p></p></p><p><p><span style="font-size: 18pt;"><strong>Operator</strong></span></p></p><p><p><span style="font-size: 18px;"> <strong>Arithmetic Operators (+-*/)</strong></span></p></p><p><p><span style="font-size: 18px;"> <strong>Find remainder operator%</strong></span></p></p><p><p><span style="font-size: 18px;">The data type on either side of the find operator must be an integer</span></p></p><p><p><span style="font-size: 18px;"> <strong>Self-increment (decrement) operation + + (--)</strong></span></p></p><p><p><span style="font-size: 18px;"><strong> </strong>When a self-increment operator appears separately</span></p></p><p><p><span style="font-size: 18px;">value++; Value = value + 1;</span></p></p><p><p><span style="font-size: 18px;">++value; Value = value + 1;</span></p></p><p><p><span style="font-size: 18px;">When a self-increment operator is used in conjunction with another operator</span></p></p><p><p><span style="font-size: 18px;">Relult = value++; Equivalent to Relut = value, Value = value + 1;</span></p></p><p><p><span style="font-size: 18px;">Relult = ++value; Equivalent: value = value + 1; Relut = value;</span></p></p><p><p><span style="font-size: 18px;"> <strong>Summary:</strong> The operator is preceded by a self-increment, in the participating operation<br>The operator is then involved in the operation, doing the self-increment operation</span></p></p><p><p><span style="font-size: 18px;"> <strong>Compound operators</strong></span></p></p><p><p><span style="font-size: 18px;">A + = b; <span style="font-size: 18px;">//a = a + b;</span><br>a-= b; A = a-b;<br>A *= b; A = A * b;<br>A/= b; A = a/b;<br>a%= b; A = a% b;</span></p></p><p><p><span style="font-size: 18pt;"><strong>An expression, a statement</strong></span></p></p><p><p><span style="font-size: 18px;">Expression: a formula consisting of constants, variables, and operators; expressions have return values, no semicolons</span></p></p><p><p><span style="font-size: 18px;">Statement: statement ends with a semicolon, which is the smallest unit of program execution</span></p></p><p><p></p></p><p><p><span style="font-size: 18pt;"><strong>Formatted output input</strong></span></p></p><p><p><span style="font-size: 18px;"> <strong>Formatted output: printf ()</strong></span></p></p><p><p><span style="font-size: 18px;">printf ("%4d\n", a); right-aligned 4-bit Output</span></p></p><p><p><span style="font-size: 18px;">printf ("%-4d%d\n", a, b); Left-justified for <span style="font-size: 18px;">4-bit</span> output</span></p></p><p><p><span style="font-size: 18px;">printf ("%04d\n", a); with 0 placeholder output</span></p></p><p><p><span style="font-size: 18px;"> <strong>Placeholders for different types of variables are summarized:</strong></span></p></p><p><p><span style="font-size: 18px;"> <span style="font-size: 18px;"><span style="font-size: 18px;">Integral type: short%d<br>int%d<br>Long%ld</span></span></span></p></p><p><p><span style="font-size: 18px;"><span style="font-size: 18px;"><span style="font-size: 18px;">unsigned long%lu<br>Long Long%lld</span></span></span></p></p><p><p><span style="font-size: 18px;">Float Type: float%f<br>Double%lf</span></p></p><p><p></p></p><p><p><span style="font-size: 18px;">Character Type: char%c</span></p></p><p><p><span style="font-size: 18px;">string:%s</span></p></p><p><p></p></p><p><p><span style="font-size: 18px;"> <strong>Format Input function scanf ()</strong> </span></p></p><p><p> <span style="font-size:24px;"><span style="font-family: ' Pingfang sc ';"><span style="font:18.0px ' PingFang SC ‘; font-variant-ligatures:no-common-ligatures; Color: #1d9421; "> in <span style="font:18.0px Menlo; font-variant-ligatures:no-common-ligatures; color: #1d9421;">scanf<span style="font:18.0px ' Pingfang SC '; font-variant-ligatures:no-common-ligatures; Color: #1d9421; "> <span style="font:18.0px Menlo; font-variant-ligatures:no-common-ligatures; color: #1d9421;">\n< in the input function Span style= "font:18.0px ' Pingfang SC '; font-variant-ligatures:no-common-ligatures; Color: #1d9421; " > will cancel out the return on the keyboard </span> </span> </span> </span> </span> </span> </p></p><span style="font-size: 18px;">What do <span style="font-size: 18px;"><span style="font-family: ‘PingFang SC‘;"><span style="color: #1d9421;"><span style="font: 18.0px Menlo; font-variant-ligatures: no-common-ligatures; color: #1d9421;"> <span style="font: 18.0px ‘PingFang SC‘; font-variant-ligatures: no-common-ligatures; color: #1d9421;">you enter in</span> scanf</span></span></span></span> ?</span><span style="color: #1d9421; font-family: PingFang SC;"><span style="color: #1d9421; font-family: PingFang SC;"><span style="font-size: 18px;">scant is extracting data from the keyboard buffer</span></span></span><span style="font-size: 18px;"><span style="font-size:18px;"><span style="font-family: ' Pingfang SC ';"><span style="color: #1d9421;"><span style="font:18.0px Menlo; font-variant-ligatures:no-common-ligatures; Color: #c32275; "> int <span style="font:18.0px Menlo; font-variant-ligatures:no-common-ligatures; >a = <span style=" font:18.0px me nlo font-variant-ligatures:no-common-ligatures; color: #0435ff; ">0<span style="font:18.0px Menlo; font-variant-ligatures:no-common-ligatures;" ; < span> </span> </span> </span> </span> </span></span></span><span style="font-size: 18px;"><span style="font-size:18px" , "><span style=" font-family:menlo; "><span style=" font:18.0px Menlo; font-variant-ligatures:no-common-ligatures; Color: #3d1d81; "> Printf<span style="color: #1d9421;"><span style="font:18.0px Menlo; font-variant-ligatures:no-common-ligatures;"> (<span style="font:18.0px Menlo; font-variant-ligatures:no-common-ligatures; color: #c91b13;"> "<span style=" font:18.0px ' Pingfang SC '; font-variant-ligatures:no-common-ligatures; Color: #c91b13; "> Please enter an integer <span style="font:18.0px Menlo; font-variant-ligatures:no-common-ligatures; color: #c91b13;">\n " Span style= "font-family:menlo;" ><span style="color: #1d9421;" ); < span> </span> </span> </span> </span> </span> </span> </span> </span> </span></span><span style="font-size: 18px;"><span style="font-size:18px;"><span style="font:18.0px Menlo; font-variant-ligatures:no-common-ligatures; color: # 3d1d81; "> Scanf<span style="font-family: ' Pingfang SC ';"><span style="color: #1d9421;"><span style="font:18.0px Menlo; font-variant-ligatures:no-common-ligatures; "> (<span style="font:18.0px Menlo; font-variant-ligatures:no-common-ligatures; color: #c91b13;"> "%d" <span style="font-family: ' Pingfang SC ';"><span style="color: #1d9421;"><span style="font-family:menlo;" ", &a); < span> </span> </span> </span> </span> </span> </span></span></span></span></span><span style="font-size: 18px;"><span style="font-size:18px" , "><span style=" font-family:menlo; "><span style=" font:18.0px Menlo; font-variant-ligatures:no-common-ligatures; Color: #3d1d81; "> Getchar<span style="color: #1d9421;"><span style="font:18.0px Menlo; font-variant-ligatures:no-common-ligatures; ">(); <span style="font:18.0px Menlo; font-variant-ligatures:no-common-ligatures; color: #1d9421;">//<span style=" font:18.0px ' Pingfang SC '; font-variant-ligatures:no-common-ligatures; Color: #1d9421; "> Remove a character from the keyboard buffer </span> </span> </span> </span> </span> </span> </span></span> <span style="font-size: 18px;"><span style="font-size:18px;"><span style="font:18.0px Menlo; font-variant-ligatures:no-common-ligatures; color: # 3d1d81; "> Rewind<span style="font-family: ' Pingfang SC ';"><span style="color: #1d9421;"><span style="font:18.0px Menlo; font-variant-ligatures:no-common-ligatures; "> (<span style="font:18.0px Menlo; font-variant-ligatures:no-common-ligatures; color: #78492a;">stdin<span style="font-family: ' Pingfang SC ';"><span style="color: #1d9421;"><span style="font:18.0px Menlo; font-variant-ligatures:no-common-ligatures;">) ; <span style="font:18.0px Menlo; font-variant-ligatures:no-common-ligatures; color: #1d9421;">//<span style=" font:18.0px ' Pingfang SC '; font-variant-ligatures:no-common-ligatures; Color: #1d9421; "> clear keyboard buffers all contents </span> </span> </span> </span> </span> </span> </span> </span> </span> </span> </span></span> <span style="font-size: 18px;"><span style="font-size:18px;"><span style="font:18.0px Menlo; font-variant-ligatures:no-common-ligatures; color: # c32275; "> char <span style="font-family: ' Pingfang SC ';"><span style="color: #1d9421;"><span style="font:18.0px Menlo; Font -variant-ligatures:no-common-ligatures; ">c = <span style="font:18.0px Menlo; font-variant-ligatures:no-common-ligatures; color: #0435ff;">0<span style="font-family: ' Pingfang SC ';"><span style="color: #1d9421;"><span style="font-family:menlo;" "< span> </span> </span> </span> </span> </span> </span> </span></span></span></span> <span style="font-size: 18px;"><span style="font-size:18px;"><span style="font:18.0px Menlo; font-variant-ligatures:no-common-ligatures; color: # 3d1d81; "> Printf<span style="font-family: ' Pingfang SC ';"><span style="color: #1d9421;"><span style="font:18.0px Menlo; font-variant-ligatures:no-common-ligatures; "> (<span style="font:18.0px Menlo; font-variant-ligatures:no-common-ligatures; color: #c91b13;"> "<span style=" font:18.0px ' Pingfang SC '; font-variant-ligatures:no-common-ligatures; Color: #c91b13; "> Please enter a character <span style="font:18.0px Menlo; font-variant-ligatures:no-common-ligatures; color: #c91b13;">\n " Span style= "font-family: ' Pingfang SC ';" ><span style="color: #1d9421;"><span style="font-family:menlo;" ); < span> </span> </span> </span> </span> </span> </span> </span></span></span></span></span><span style="font-size: 18px;"><span style="font-size:18px;"><span style="font-family: ' Pingfang SC ';"><span style="color: #1d9421;"><span style="font:18.0px Menlo; font-variant-ligatures:no-common-ligatures; Color: #3d1d81; "> Scanf<span style="font:18.0px" (<span menlo; font-variant-ligatures:no-common-ligatures; color: #c91b13; "> "%c" <span style="font:18.0px Menlo; font-variant-ligatures:no-common-ligatures;" ", &c); < span> </span> </span> </span></span></span></span></span> <span style="font-size: 18px;"><span style="font-size: 18px;"><span style="font-family: Menlo;"><span style="font: 18.0px Menlo; font-variant-ligatures: no-common-ligatures; color: #3d1d81;">printf<span style="color: #1d9421;"><span style="font: 18.0px Menlo; font-variant-ligatures: no-common-ligatures;">(<span style="font: 18.0px Menlo; font-variant-ligatures: no-common-ligatures; color: #c91b13;">"a =%d, c =%c\n"<span style="color: #1d9421;"><span style="font: 18.0px Menlo; font-variant-ligatures: no-common-ligatures;">, a, c);</span></span> </span> </span></span> </span></span></span></span><p><p>iOS Learning C language Day01</p></p></span>