In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you the gcc character formatting input and output, expression operator do while loop example analysis, I believe that most people do not know much about it, so share this article for your reference, I hope you will learn a lot after reading this article, let's go to know it!
Output function: printf () -% d,% c,% x,% u,% s,
Putchar () function: output
Input function: scanf function-input
Gets the data of the specified type according to the specified format match
Int a; / / you can define a variable (with memory space) or declare it (automatically promoted to definition, with memory space)
Scanf ("% d", & a); / / & take the address of the variable an and get the memory space of a
Scanf input: getting characters in
Getchar function: getting characters
Operator-arithmetic operator
+, -, *, /: multiply, divide and take the remainder, then add and subtract
After the division operation, the result is assigned to the integer variable, taking the integer part, int c = 20prime 40.
Except 0, error operation, not allowed, printf ("% d\ n", 20max 20)
Take the balance to 0, error operation, not allowed, printf ("% d\ n", 1234ap0)
The remainder of the decimal is not allowed.
If you take the remainder of a negative number, the result is the absolute value of the remainder.
Self-increasing and self-subtracting operator
Prefix self-increment (increment operator): (+ +), self-subtraction (decrement operator): (- -): first increase, decrease, and then take a value
Assignment operator: =
"=", in the computer, can only complete the assignment operation, must be the right side of the assignment to the left, also known as one-way assignment and so on.
A + = 10; / / equivalent to a = axi10
A-= 30; / / equivalent to a = a muri 30
A% = 5; / / is equivalent to a = a% 5; comparison operator
True: 1 (non-0), false: 0
! = unequal,
< 小于、>Greater than or equal to
Logical operators: 0 is false, non-0 is true, (non-zero 1, 27,-9)
Logic is not:!
Non-true is false, non-false is true
Logic and (& &): the same truth is true and the rest is false.
Logic or (| |): true is true, and false is false.
Operator precedence: [], (), +, /,--
Suffix is higher than prefix (strong turn)! (logical non) sizeof > arithmetic operator (first multiply, divide and subtract the remainder) > comparison operator > logical operator > trinomial operator (conditional operation) > assignment operator > comma operator
Comma operator:
Int x, y, z
Int a = (x = 1, y = 2, z = 3) / / comma operation expression, the result is: a = 3
The result of the comma operator expression operation, which displays the result of the latter subexpression
Ternary operator
Syntax: expression 1? Expression 2: expression 3
Expression 1: must be a judgment expression
The result is true: the whole trinocular operation returns expression 2, the result is false, the whole trinocular operation returns expression 3
Type conversion: implicit type conversion, forced type conversion
Editor is automatically completed, small type to large type, the same type size
Generated by assignment
Int r = 5
Float s = 3.14 * r * r
3.14. The default type is double. R is int. During the operation, it is converted to double. When the operation is finished, it is converted to float when assigned to s.
There is no problem with changing a small type to a large type. If a large type is converted to a small type, the precision may be lost.
Force conversion in a class
Syntax: strong transformation quantity-(target type) variable, strong turn expression-(target type) expression
If branch statement
If (judgment expression) {
Can it be executed if the discriminant expression is true?
}
Else
{
Judge whether the expression is false and execute the code
}
Multi-branch logic
If (judgment expression 1)
{
Judge that expression 1 is true and execute the code
}
Else if (judgment expression 2)
{
Judge whether expression 1 is false, judge expression 2 is true, and execute the code
}
Else if (judgment expression 3)
{
Judge whether expression 1 is false, judge expression 2 is false, judge expression 3 is true, execute code
}
Switch branch statement
Switch (discriminant expression)
{
Case 1:
Execute statement
Break;// indicates the end of execution of a branch statement and jumps out of the switch
Case 2:
Execute statement
Break
.
Case n:
Execute statement
Break
Default
Break
}
Accurate matching, clear mechanism, higher execution effect than if statement
Case penetration
A case branch, if there is no break, each time the case code is executed, it will continue to go down and execute the next case branch code, which is called case traversal.
In most cases, a case branch should correspond to a break that takes advantage of case tradition
While loop statement
Syntax: while (judgment expression) / / if true, execute the loop body, if false, jump out of the loop
{
Cyclic body
}
Do... while Loop statement
Syntax: do {
Cyclic body
} while (judgment expression)
These are all the contents of the article "character formatting input and output in gcc, example Analysis of expression operator do while Loop". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.