C ++ day02 Study Notes

Source: Internet
Author: User

1.% LDD executable file name; --- view the Connection Library

2. c ++ is case sensitive. Only letters, numbers, and underscores are allowed for variable naming. The first letter must contain letters or underscores.
3. Float Single-precision and double-precision
Sizeof (INT) --- return the size of the int in memory
Size (bool) = 1
Size (char) = 1
Size (short) = 2
Size (INT) = 4
Size (long) = 4
Size (float) = 4
Size (double) = 8
Once the unsigned data overflows, it becomes 0.
The maximum value of a signed Int Is 2147483647. Overflow is changed to the minimum value and negative value.
4. assign values between different data types: compatible data types that occupy a small amount of space. You can assign values to data types that occupy a large amount of space.
Incompatible, may cause data loss. INT-> float can be converted; float-> int decimal part is lost

5. Operators
The data types must be the same
I ++ first use and then add
++ I prefix and use
Boolean operator number: true or false result
Logical operators: Perform bool operations! (1) "and" Operation &, the two conditions must be both true (2) "or" Operation |, as long as one condition is true, it is true

6. The result of bitwise AND "&" having 0 is 0.
Bitwise OR "|" has 1 or the result is 1.
If the bitwise OR "^" is different, the value is 1 and the value is 0.

7. Shift left "<" to left 1 equals to multiply by 2
Shift right ">" shift right 1 equals to divide by 2

8. Three-object Operator
Condition? True: false

9. Return variable --- the expression can be assigned a value again. The value assignment statement returns the variable itself. For example: (A = 10) = 20
Return the value of the variable --- the value cannot be assigned again. For example: (A + 5) = 10
Left value: variable and value expression. The return value of ++ I is the left value.
Right value: the right value cannot be placed on the left of "=", and the return value of I ++ is the right value.

A constant must be assigned a value during declaration and cannot be modified.

10. Process Control
When the while (condition) {loop body} condition is true, it enters the loop. When the condition is false, it exits the loop.
(1) Declare cyclic Variables
(2) While () determines the cyclic Condition
(3) The cyclic variables must change to avoid endless loops.
For (variable initialization; condition; variable changes) {loop bodyCode}
Determine whether the cycle condition is true at the beginning. After the cycle ends, use the variable to change to the third condition.
Do {loop body} while (condition );
Execute the statement once, then judge the condition, and select whether to continue the execution cycle.

Break; jump out of the loop and execute the next statement other than the loop
Continue; starts from the second point, ends this cycle, and carries out the next cycle

11. Classroom exercise --- calculate all prime numbers between 1 and 100

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.