Hello, it's time for me to sum up my classroom knowledge. What you learned today in the cloud and college is the IF statement under Select Structure in C #. Here's a summary of what you've learned today.
theory : The IF statement is the most common choice structure statement. It is determined whether to execute the following block of statements, depending on whether the given condition (often consisting of a relational expression and a logical expression) is true. The IF statement has three types of structure:
Real :1. an IF structure of a select path
if (condition) { statement block;} // If the condition is true, the following statement block is executed, or if the condition is false, the IF statement ends. If the statement has only one line of code, the braces on the outer layer of the structure can be omitted.
For example:
Namespace Practice 005_ user Input { class program { static void Main (string[] args) { if (5>10) Console.WriteLine ("5:10 Large");}}}
2. The IF structure of two selected structures
For example : The user enters a year, and if it is run year, the output is true, and if not, the output is false.
3. If structure for multiple selection paths
if (condition)
{
Statement Block 1;
}
else if (condition 2)
{
Statement Block 2;
}
.
.
.
Else
{
statement block N;
}
In this structure, when the value of condition 1 is true, the statement block 1 is executed, and then the IF statement ends; otherwise, if the value of condition 2 is true, the statement block 2 is executed, and so on. If all conditions are not true, then the last else statement block N is executed.
For example: test results evaluation
Console.WriteLine ("Please enter your score");
int score = Convert.ToInt32 (Console. ReadLine ());
if (score >=90)
{
Console.WriteLine ("The student's performance is assessed as: A");
Console.readkey ();
}
else if (score >=80 && score <90)
{
Console.WriteLine ("The student's performance is assessed as: B");
Console.readkey ();
}
else if (score >=70 && score <80)
{
Console.WriteLine ("The student's assessment result is: C");
Console.readkey ();
}
else if (score >= && score < 70)
{
Console.WriteLine ("The student's assessment result is: D");
Console.readkey ();
}
Else
{
Console.WriteLine ("The student's assessment results are: E");
}
Console.readkey ();
Well, today summed up here, looking forward to tomorrow's meet again. Come on, enze!.
Enze Third Day (select Structure "If...else" in C #)