Today we are mainly talking about the basis of C. This time we will mainly explain it in detail by code.
First of all, the biggest headache is the difference between a = I ++ and a = ++ I. a = I ++ first assigns a value and then increases itself, a = ++ I is auto-incrementing first and then assigned a value.
Int I = 5;
Int B = I ++;
Int c = I;
Printf ("B = % d \ n", B );
Printf ("c = % d \ n", c );
Int a = ++ I + (B ++ );
Printf ("a = % d \ n", );
Printf ("B = % d \ n", B );
Int d = I + B;
Printf ("d = % d \ n", d );
Printf ("*********************** \ n ");
Int z = 1;
Int j = z ++;
// J = 1 z = 2
Printf ("z = % d", z );
Printf ("j = % d \ n", j );
J = ++ z;
// J = 3 z = 3
Printf ("z = % d", z );
Printf ("j = % d \ n", j );
J = z --;
// J = 3 z = 2
Printf ("z = % d", z );
Printf ("j = % d \ n", j );
J = -- z;
// J = 1 z = 1
Printf ("z = % d", z );
Printf ("j = % d \ n", j );
Printf ("*********************** \ n ");
Any language will use judgment. Let's talk about if else first.
Printf ("*********************** \ n ");
I = 0;
If (I ){
Printf ("true \ n ");
} Else {
Printf ("false \ n ");
}
Printf ("********************** \ n ");
Determine the maximum number of three values without using the median.
Printf ("********************** \ n ");
A = 8;
B = 4;
C = 1;
Int max = 0;
If (a> B ){
If (a> c ){
Max =;
} Else {
Max = c;
}
} Else {
If (B <c ){
Max = c;
} Else {
Max = B;
}
}
Printf ("max: % d \ n", max );
Printf ("********************** \ n ");
Switch statement
Printf ("********************** \ n ");
Char char_grade;
Printf ("Enter :");
// Scanf ("% c", & char_grade );
Switch (char_grade ){
Case 'A ':
Printf ("90-100 \ n ");
Break;
Case 'B ':
Printf ("80-90 \ n ");
Break;
Case 'C ':
Printf ("70-80 \ n ");
Break;
Default:
Printf ("enter \ n" again ");
Break;
}
Printf ("********************** \ n ");
Author 10-3G-Cheng Long