Hello and welcome to Golden Programming Languages course in this session, we want to talk about decision
making concert.
Go, Lang, decision making decision making in programming is similar to decision making in real life,
in decision making.
A piece of code is executed when the given condition is fully filled.
Sometimes these are a turn as the control follows, statements go.
Lang uses control statements to control the flow of execution of the program based on certain conditions.
These are used to cause the flow of execution to advanced and branch based on changes to the estate
of the program.
Like most programming languages, Go Blank borrows several of its control flow syntax from the CFMEU
of Languages.
Ingo Lang.
We have the following conditional statements The E-4 statement executes some code in one conditions
through the FLC Elsa statement executes some code if a condition is true and another code if that condition
is false.
This that if a statement you can use one e for else if a statement inside another, if or LCP statements
the f l steve.
As the statement executes different codes for more than two conditions and the suj case, the statements
selects one of many blocks of code to be executed.
If a statement.
This is the simplest decision making a statement.
It is used to decide whether a certain statement or block of his statements will be executed or not.
If a certain condition is true, then a block of a statement is executed, otherwise not.
Now you can see the flow diagram of if a statement.
If the condition of the true value, so if black executed, otherwise, if black does not execute,
now let's go to this school and illustrate how to use if a statement
first go to Project Expeller, create a folder name like decision making.
And define a fine inside, it's like Maine does go.
Said Package name, package main and define the main function, find me OK in this sandpit, we want
to print a message based on the condition.
So first, define two variables like VAT A by the type end and initialize eat what 10 value and define
and other like Line B by the tight end and initialize eight by 20.
Now write a condition for the example if a variable value list, then be variable value.
So print a message for us.
So we run if.
A list and be open and close races and sit out a state mass here.
So we FP.
A value is less than.
Be value, OK, reform at the court, save the project and execute the program, so go to Terminal First,
go to Project Folder, see the decision making funeral scheme and run the program by the comment go
round or back as this may go.
Now you can see the output.
A value is less than be value.
The value of the value of an A is less than the value of the variable P.
It means 10 less than 20.
So our condition returns to value and the statements inside the F block are executed and printed.
The message a value is less than P value in order not to prolong the time of decision.
We will finish it and we will continue the content in the next session.
Goodbye.