iosday01c Language data types

Source: Internet
Author: User

1. Comments

Single-line Comment
Annotations act as explanations to the code, and annotations are for programmers, not programs.
/*
Multi-line comments
Xcode shortcut Keys
Select All Cmd+a
Copy Cmd+c
Paste Cmd+v
Set cmd+,
Comment cmd+/
Run Cmd+r
Compiling cmd+b
*/

2. Conversion into the system


3. Data type

  

? float and double difference: accuracy is not the same.     ? float Effective digits are 6 bit .     ? double Effective digits are 15 bit . Number of significant digits: from the number on the left, not 0 , to the exact number , all numbers.

4. Constants, variables

1> Constants : Amount that cannot be changed during program operation
Integer constant 10,-100
Floating-point constants: 20.3, 3.5
Character-type constants: ' A ', ' f ', ' ', ' 1 '

2> variables : Variables can be modified during the program run, variables are a storage area, the contents of the store can be changed
    Definition of a variable
Type modifier variable name = initial value;
=: assignment operator, which assigns a value of 18 to the age

      1int age =;   

    Variable name naming rules

1. Can only be composed of letters , numbers , underscores ,$ , cannot start with a number

2. cannot have the same name as the system reserved word

3. Variable name names cannot be duplicated

4. See the meaning of the name (specification)

5. Hump nomenclature ( in the case of multiple words, the first letter is lowercase, starting with the second word, capitalized in the first letter)

5. Operators

1> arithmetic operator (+-*/)

2> calculation remainder operator %

The data type on either side of the find operator must be an integer

3> self-increment (self-subtraction) operation + + (-)

    When a self-increment operator appears separately

// value = value + 1;    // value = value + 1;

When a self-increment operator is used in conjunction with another operator

      relult = value++; Equivalent to Relut = value, value = value + 1;

      relult = ++value; Equivalent to value = value + 1; Relut = value;

    Summary: operator is preceded, self-increment, in the participating Operation 
The operator is then involved in the operation, doing the self-increment operation

4> compound operator 

1        A + = B; // A = a + B; 2 // A = a -B; 3 // A = a * b; 4 // A = A/b; 5 // A = a% B;

6. Expressions, statements

  expression : An expression consisting of constants , variables , and operators with return values , without semicolons

  Statement : statement ends with a semicolon, which is the smallest unit of program execution

7, formatted output input

1> formatted output:printf ()  

1 printf ("%4d\n"//  right-aligned accounted for 4-bit output 23 printf (  "%-4d%d\n"//  left-aligned 4-bit output 45 printf (" %04d\n " // with 0 placeholder output

    Placeholders for different types of variables are summarized:

      Integral type: Short%d
int%d
Long%ld

unsigned long%lu
Long Long%lld

Float type: float%f
Double%LF

Character type: Char%c

String:%s

Address:%p

    Escape character

      

2> Format Input function scanf ()    

in scanf input function do not allow to appear \n keyboard and enter

What do you enter in scanf ?     scanf is extracting data from the keyboard buffer  
1     intA =0;2printf"Please enter an integer \ n");3scanf"%d", &a);4GetChar ();//Take a character out of the keyboard buffer5Rewind (stdin);//clears all contents of the keyboard buffer6     Charc =0;7printf"Please enter a character \ n");8scanf"%c", &c);9printf"A =%d, c =%c\n", A, c);

iosday01c Language data types

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.