One, operator
Relational operators
Relational Operators |
meaning |
the expression in mathematics |
< |
Less than |
< |
<= |
Less than or equal to |
≤ |
> |
Greater than |
> |
>= |
Greater than or equal to |
≥ |
== |
Equals |
= |
!= |
Not equal to |
≠ |
Conditional operators
max = (a>b)? A:B;
logical operators
operator |
Description |
Binding Nature |
Example |
&& |
and arithmetic, binocular, corresponding to the "and" in mathematics |
Left combination |
1&&0, (9>3) && (b>a) |
|| |
or arithmetic, binocular, corresponding to the "or" in mathematics |
Left combination |
1| | 0, (9>3) | | (B>a) |
! |
Non-arithmetic, monocular, corresponding to "non" in mathematics |
Right combination |
!a,! (2<5) |
Two, branch structure
If Else
Non-bint in (Char *str) {char *str1= "a";p rintf ("strcmp (str, str1):%d\n", strcmp (str, str1)); if (strcmp (STR,STR1) ==0) { return 1;} else{ return 0;}}
Switch
Satisfies the case condition: there is a break that jumps out of the loop, and no break resumes execution of subsequent non-satisfied case conditions.
#include <stdio.h>int main () { int A; printf ("Input integer Number:"); scanf ("%d", &a); Switch (a) {case 1:printf ("monday\n"); Case 2:printf ("tuesday\n"); break; Case 3:printf ("wednesday\n"); break; Case 4:printf ("thursday\n"); break; Case 5:printf ("friday\n"); break; Case 6:printf ("saturday\n"); Case 7:printf ("sunday\n"); default:printf ("error\n"); } return 0;}
Third, the cycle structure
For
Break jumps out of the loop
int arr1 (int n,int arr[]) {for (int i=0;i<n;i++) printf ("%d", Arr[i]); return arr[i];}
C language--operators, branching structures, looping structures