Sharing! What gained.

Feb 1, 2016

How To Declare Variables and How to Use Them and basic Input Output statements


Variables Types:

Variables are the basic block's of any programming language now in some languages there are formal names for declaring them while on the other side of spectrum some languages do not demand specific names for declaring them i.e Python etc. In most of the language we follow the specific syntax for declaring them.
Variable  in programming is just like a variable that you used in calculus,Linear Algebra etc but here for declaring almost every thing you will first have to assign it to a variable to make your code more dynamic and less static,By dynamic I mean you can make you application or program more user friendly.

How TO Declare Them?

Almost all the language that I have personally used so far have a very slightest difference of declaring the data Type.We will stick to Vb(Visual Basic) here
So,Like in every other language variable declaration Structure, Visual Basic have also its own Variable declaration structure which is not much different from other languages

Dim <variable name> As <data type>

Now I will explain each and every part of the declaration structure.Let's start with DIM ,You must be thinking what does Dim do ?It's some thing that's different and new for a programming who have worked in other languages like C++,C# etc Dim actually tells the computer that what type of the data is been declared and what type of the data is given by the user or in other words Declares and allocate storage space for variables then the second part is the name of the variable which we will use to use it during writing out code just lie we declare  X in calculus or Linear Algebra and the last part is telling the computer what type of the data is declared i.e string,integer,double or float etc.
Now I will conclude by a piece of code which will show the declaration of variables.
 

 How to use them together in same code?How to use input output statements?

Now next we will see how to use each one of them through a coding examples


 In Visual basic we take output by writing "Console.WriteLine("Enter the variable name or string you want to print")" and for input you we will simply use "Console.ReadLine()" now if you see this code we have printed the string whose name is A1 then we have taken a number and by putting '='(assignment operator) we have assigned the value to the integer type variable we named var1 that we have taken from the user then we have repeated the same thing to enter the value in B1(name of variable declared) then by  / operator we have divide the values that we have assigned to A1 & B1 .



Share this Post!

0 comments:

Post a Comment