Hello and welcome to the Golang programming language course in this session.
We want to continue the variable concept.
Go variables, declaration and initialization.
In the last session, we said a debt in gold language warrior bills are created in two different ways.
The first method using via keyboard and the second method through short variable declaration.
In this session, we want to examine the types of variables in the village school environments.
First, we will start with the bad keyboard method and examine the different modes of creating a variable.
So open the village and create the sample project.
Go to Project Explorer, create a folder name, for example, variables.
And create a fight inside it, like Maine does not go first, define the package name package Maine
and define a main function, find me.
Incorporate any language when a project is executed, the compiler first reads and executes the main
function and main function is this talking point of the project and goal language?
Now it's time to define the types of variables.
First, we examine the different cases of variable definition by that keyword first case in the vast
syntax.
Either type or equals the expression can remove, but not both can remove in the declaration of the
variable.
So first, consider the case where the type is deleted.
If the type is removed, then the time of the variable is determined by the value initialized in the
expression.
Now let's do an example for this case.
First, define three variables that declared and initialized without the explicit type.
For example, VAR variable one equals 100.
This variable doesn't have any type, but initialize a 100 value 100 value type is integer, so the
type of variable one should be integer.
Go to the next line and define another variable, for example, VAR variable.
Two equals the initialized this variable by a string value.
Go through Koranic language
and go to the next line.
That variable three equals seven hundred and fifty point three hundred and forty five.
Variable three light another variable doesn't have any type and the initialize eight by 750 point 345.
So this variable gets fellow type to itself for display and print variables.
We use the print f function from the empty package.
The print f method consists of two parts the first part which specifies the text and data type.
And the second part, which is separated from the first part by a comma.
We enter the name of the variable used now.
Display the value above.
So do the following if 20 dots print f.
For the first part, we write the value of variable.
One is here we use from the conversing character or formatted string.
The printed familiar function uses person character as a placeholder when that person is encountered.
Print ever reads the characters following the person to determine what to do.
For example, a person is take the next argument and print it as a street or person to take the next
argument and print it at an integer value.
So for the variable one, we set per cent d because the type of that variable is integer and go to the
next part and set name of that very big variable.
One.
Go to the next line and print type of the variable.
So we write F.A. down print f the type of variable one equals or column.
In this case, we said person t all per case for format is sitting or condition characters for display
a type of a variable.
So we write and T uppercase and set a variable variable one.
So we could display value and type of the variable by the Person D in person.
T we use from Person D, character B.
Because the vanity Bill Van has an integer value, so go to the next line and display values and types
of variable two and variable three.
So right again, F.A. don't paint if the value of variable to color variable too has a string value.
So we said percent s lowercase as format asking for this variable and go to the next part and said.
Many about to go to the next line and display type of disparity, even if empty dot print f did tie
all variables to color.
We use from person to operate a case as formatted string for this variable, so sit variable.
To.
And go to the next line and display value and type of variable to the you right?
F.A. got printers in first fiction.
Write the value.
Of Variable three column, because the initialize the variable three by a float value, so we use from
percent f lowercase as conversion character or a string for person f, and in the next session, we
set name of the value of one variable three and go to the next line and display type of this variable
F.A. dot print f.
The type of value the three color person t uppercase because we want to display the type of a variable
we use from person T uppercase and go to the next section, insert name of Variable Y did in three.
Okay.
Reformat the call, save the project and execute the program.
First, go to a terminal, go to a project folder.
See the variables clear screen and execute program by the comment.
Go run dot Manchester's main dot go.
Now we can see the output, what the values are printed consecutively on the lines to be able to print
its value on a separate line.
We use batches and as a control character so that we can print each value on the new line.
So we put backslash and in the end of the first section of each display.
So we said backslash and.
Save the project and go to terminal and execute again.
Now we can see each value display in separate line, for example, the value of a variable one is 100
in type of it is integer value or variable.
Two is go programming language and type of it is string and value of variable threes is seven hundred
and fifty point three hundred and forty five, and type of it is float sixty four in future chapters.
We will talk in detail about the data types and the various printing methods of the F.A. package.
In order not to prolong the time of decision, we will finish it and we will continue the content in
the next session.
Goodbye.