sequence of program execution;
1. Sequential structure
2. Conditional structure, if conditional structure, IF...ELSE conditional structure, multiple if conditional branching structure (if...elseif). else) and the switch conditional structure
3. Loop structure: Do....while loop, while loop, for loop
Operator:
Arithmetic operators (categorized by operands)
1. Unary operator ++,--
2. Two-dollar operator; +,-,*,/,% (modulo or remainder)
Assignment operator: =
Compound assignment operator; +=,-=,*=,/=.%=
Comparison operators: Comparing the size relationships of numeric values (<,>,<=,>=,!=,==)
Logical operators: With && or | | Non -!
with (and): Multiple conditions at the same time for true results to be true =è a false than false
or (OR): in multiple conditions as long as one condition is true, its structure is true =è true
Non- ( take counter ): It's not true, it's not fake.
If condition structure: Executes the statement within its curly braces if the condition is established
if (condition) {
Statement
}
Example:
int A;//DECLARE variable
printf ("Please enter Age");//Output
scanf ("%d", &a);//input
if (a>=18) {//Judging condition
printf ("You are already an adult");
}if (a<18) {
printf ("Minors");
}
IF...ELSE Conditional structure: Judge the condition to execute its if under curly brace statement, otherwise execute else inside statement
if (a>=18)
{
printf ("adult");
}else{
printf ("Minors");
}
Determine whether the number of daffodils;
int num,ge,shi,bai,he;//declares integer input values, bits, 10 bits, hundred, and
printf ("Please enter a three-digit number");
scanf ("%d", &num);//input%d integer placeholder & outlaw Value
Digit Three square + 10 bit three square + hundred three times for Narcissus number
1. Get the digit
ge=num%10;
2. Get 10-bit
shi=num/10%10;
3. Get hundreds
bai=num/100;
He=ge*ge*ge+shi*shi*shi+bai*bai*bai
if (he=num) {//Determine if the number of daffodils is
printf ("%d daffodils;", num);
}else{
printf ("%d is not narcissus number;", num);
}
Implement the Scissors game : user A and user B Enter the punches separately (0: scissors , 1: Stone , 2: cloth )
int usera,userb;
/1. Get users separately A and User B The punch out of the
printf ("Please a player punch:0 for Scissors,1 for Stone, 2 for cloth \ n");
printf ("Please User A punch:");
scanf ("%d", &usea);
printf ("Please User B punch:");
scanf ("%d", &USEB);
2. based on user A and User B comparison of the punches made
//UserAwin==> (Usera:0 (Scissors) &&UserB:2 (cloth));(UserA:1 (Stone) &&Userb:0 (Scissors));(UserA:2 (cloth) &&UserB:1 (Stone))
if ((usera==0&&userb==2) | | | (usera==1&&userb==0) | | (usera==2&&userb==1))
{
printf ("User A You Won");
Draw ==> user a== user B
if (Usera==userb)
}
{
printf (" really bad, draw ~~~~~~~~~\n");
}
//UserBwin==> (Usera:0 (Scissors) &&UserB:1 (Stone));(UserA:1 (Stone) &&UserB:2 (cloth));(UserA:2 (cloth) &&Userb:0 (Scissors))
if ((usera==0&&userb==1) | | | (usera==1&&userb==2) | | (usera==2&&userb==0))
{
printf ("User B wins ");
}
C Language Basic Three