I. ①int age = 20
As on the INT naming convention, int (uppercase and lowercase characters, numbers, underscores ) = ()/The contents of parentheses must start with a letter
When there are multiple words in a variable name, the first word is lowercase, the second word is capitalized (the next word is capitalized), such as Numberofpeople, and is also known as the name.
②SCANF: receiving input from the terminal must be in strict accordance with the scanf format scanf ("" ",& parameter); The parameter must be the address of the variable,,& represents the fetch address. do not add spaces between quotation marks in an easy area
Get Char: Receives one character at a time from a terminal
int operation
scanf ("",& operation), where the operation is declared variable, declares a variable (the system does not immediately allocate memory space ) and defines a variable ( allocating memory space immediately, saving the value ) has a difference
Two. Basic operators
Priority of type: short--int--float--double, from low to high.
Example: int integer converted to floating point type
① cast: Int (float) result= (float+) noun/noun;
② Stealth Conversion: Int (float) result= noun (*0.1)/noun;
a++ (Delay +1, when the statement is completed first and then add 1)
++a (immediately +1, add 1 before the statement operation): +-* Same as the arithmetic method
1?? int temp = 10
int re = (temp++) + 20
Re = 30;
2?? int re = temp + 20
ren=30;
temp = temp + 1;
Three. Conditional control statements
① Boolean value Bool:true false
Example: #include <stdbool.h>
BOOL isOK =false
②IF Conditional statement Nonzero is true, if it's 0, that's false.
if (expression) {
What will be done after the establishment
}
If Else
if (expression) {
What will be done after the establishment
}else{
Other things that are not going to be done in this situation
}
③switch statements
switch (an expression or a variable) {
The case must be a constant here:
printf ();
Break ,/If not added, the case will always be judged, and once a break is encountered, it jumps out immediately. Break is the function of jumping out of the current loop and jumping out of the switch.
Case ******:
........
Default
printf ("Unreasonable and illegal input");
16 in the binary is greater than 10: a means that 10,b means that 11,c means that the 12,d means that the 13,e means that the 14,f represents a 15 lift for example: 30 is represented as: 1E
④for Loop Statements
while (conditional statement) {
It will be done when the condition is fulfilled, and the condition will be circulated.
}
Do .... While statement
Example: Calculating 1+2+ ... Value of 100
int total =0
bo=
Total + = i;//total=total+i
i++;
}while (i<=100);
Do ... while and while are different: do ... while satisfies at least one time to execute, and while if not satisfied does not perform the following
Use the For Loop statement to calculate when 1+2+3+ ... 100 The sum of the time
1??
#include <stdio.h>
int main (viod) {
int temp = 0;
for (int i= 1; I <=100; i++) {
temp + = i;
}
printf ("%d", temp);
}
2??
#include <stdio.h>
int main (viod) {
int i = 0;
int temp = 0;
for (; I <=100; i++) {
temp + = i;
}
printf ("%d", temp);
}
I was defined earlier and can be omitted in the For statement.
3??
#include <stdio.h>
int main (viod) {
int i = 0;
int temp = 0;
for (; I <=100;) {
temp + = i;
i + +;
}
printf ("%d", temp);
}
i++ in the back, the results are constant.
The difference between break and continue: Break is to jump out of the loop, while continue is the end of the loop, directly to the next.
2015-12-03ios Class Summary