![]() Making a distinction between parameter paradigm, By Val and By Ref, is something that even seasoned programmers find difficult to explain. Parameters for Functions and Sub Procedures - By Val and By Ref The role of the variable, double, is explained in the above example, by printing the value of π.īoolean variables store the values as, True or False. In the above example, two integers are stored in the variables, a and b, then added them up and the sum is stored in the variable, c, to be printed. In the above example, the first name and last name are stored in two string variables, to be printed later as the full name. Please note the way a space is inserted by the use of " ", between the two variables. Let's use the variables, string, to store the first name, the last name and then print the full name. In this context, the choice of the right variable - even in numbers like 4, 50000 or 3.786 - determines how efficiently a programme uses memory resources. In addition, when you can carry something in a carrier bag, you don't use a sack for the same purpose. In short, the variable type does matter, when it comes to storing data. Exactly in the same way, an integer type cannot hold a string or vice versa. In real life, if a sieve is a container, it cannot hold water, but it can hold ice. These are some of the types of variables in programming languages: The type of the container determines what it can store. Variables store the information or data in the memory and act as containers. In order to address this issue, we have to learn about variables. ![]() In short, when it comes to the fifth line, it doesn' know what to print. Why?īecause, the computer hasn't stored the first name and last name in its memory, to be recalled for printing. This is what you actually happens:Īs you can see, the full name is not printed despite the first name and surname being given. In the above example, a user enters first name and surname in the hope of seeing his full name being printed. Look at the following piece of code in action:Ĭonsole.WriteLine("What's your first name?")Ĭonsole.WriteLine("What's your last name?") The comments are not executed and will not affect the flow of the programme. The following image shows the role of a comment. This is all done by the humble, old apostrophe - ' in Visual Basic.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |