Variables in Dart

Variables in Dart are similar to variables in Math. We create variables to hold unknown or temporary values at some reference. When we want them, we can use them.

If you have watched the above video, you will realise that we used (printed) variables when we wanted. To declare(tell computer that this is a variable) a variable we need to define its data type which will be ,more elaborated in next video's corresponding blog. For now we consider the syntax of writing code for declaring an integer variable is as follows:
int x ; Or
int x = 10 ;

Here in first statement we just declared a variable. In second line we declared as well as inititalized the variable as well. Inititalization is giving some value to the variable in the beginning. When we don't inititalize, the variable holds a random garbage value.

We can perform different mathematical calculations on numerial variables, like addition, subtraction, multiplication, division, modulus(finding remainder of a division), etc. Here is a sample code for the same:
void main(){
int a = 30;
int b = 6 ;
print(a+b); // Addition - 36
print(a-b); // Subtraction - 24
print(a/b); // Division - 5
print(a*b); // Multiplication - 180
print(a%b); // Modulus - 0

Need more Information?
Click here for YouTube Link
Very Easy! Follow my video lectures on YouTube link and keep reading my blog here for more information. In the video lectures, I have explained all the basic and minor details. The same content will be posted on this website if you like reading more than watching.