Skip to main content

Variables, constants and datatypes

variables, constants and datatypes

Defining and declaring variables:

Data type is an important component of every programming language, which tells the compiler, the type of data that can be stored in the variables. What is a variable then? It is a container that holds the particular type of data.

Consider a container, that is made only to hold water with maximum capacity of 10 liters. So, now we can pour water in to that container till the maximum limit. Depends on the requirement, up to 10 liters of water can be stored.

Similarly, datatype is like a container that is made only to hold water i.e. only a specific type of data can be stored. The popular data types, used by programming languages are int, float, char, double etc.

Then what is a variable, it is name of the container that holds the water, let’s name that as Water Container. In programming, it is defined as below,

int water_container;

in the above expression int is a datatype and water_container is a variable. Int can hold only integers.
Consider we are storing 2 liters of water in the container, how can we do that,
int water_container = 2; int can store only some particular bits of data which of integer type.

So, to store extra amount of amount, we need a larger container, similar to that, to store high volumes of data, we need to use other data types. This is the basic for all the programming languages.

In INFO-BASIC, the datatype need not to be explicitly mentioned as like in other programming languages.

You can just say, water_container =2;

This means, BASIC is not a strongly typed language. So, you need to care about the data type of a variable. What will you do if you want store some characters in water_container variable.

water-container = “2 liters”

Even a string can be stored in the same variable as shown above. That’s all about data type. Give a name to the variable and store some value in it, no need to specific what type of data you are storing in BASIC.

What is a constant?

Let’s consider the value of Pi. Everyone knows it is 3.14. So, these values are constants and never be changed. But a data stored in a variable can be changed.

If you are doing some mathematical calculations, that has Pi constant, how to ensure that the value of Pi remains unchanged till the end of the program. To achieve this EQU should be used. What does this EQU mean, it is nothing but EQUATE. We are equating a value to a variable to make it constant.
Below is code representation,

EQU pi TO 3.14

This statement stores 3.14 in a memory located named as pi.
Interesting! Have you noticed, EQU and TO in the above statements are capitalized. Yes, because these are keywords.

What is a keyword? Does it is something special to do with my code.

Keywords are reserved words for special purposes. We used EQU to equate the value 3.14 to pi. “TO” is also capitalized. Because it is keyword too. There many keywords in BASIC and we will come across in the forth coming chapters. Very important, these keywords should not be used as a variable.


Do you have questions, please comment below? We will respond to you at the earliest.

Comments

Popular posts from this blog

How to get 5GB instantly in seedr?

Seedr is a torrent caching site which provides 2GB of caching for free. For those who are not aware of what the torrent is?  Torrent is a peer to peer communication protocol (P2P) for file sharing. It was introduced in the mid of 2001 for decentralizing the file sharing in this real world. How the files are shared via torrent? Files are uploaded to servers as we do traditionally but the interesting part comes here, these files can be downloaded only via torrent client like Bit torrent, µtorrent, Vuze or you can use any other clients available in the market. Just do a google search to find all the available clients for downloading files.  Why they are restricting the download to clients? Because, the concept here is each computer acts as a server, once you start the download, the client will start uploading the data. Someone on the internet will download the same file based on the data you upload, this process is called seeding, thus decentralizing the data and r...

Decision making statements - T24

As a programmer, it is essential for you to make your program to work better in all the cases. So, based on the real-time data, you have to decide how the program should work. So, it is important to take decision. Consider a simple case where you want to print the number provided by the user at runtime is even or odd. How to handle that in programs? Decision making statements comes in to play. So, what is the syntax and how to use that? IF condition THEN                 This block will execute when the if condition is satisfied or validated to true. END This is the syntax of the simple IF block. Ok. If the condition is not satisfied, then what will happen. I need to do something when IF condition is failed. How to handle that? ELSE block should be introduced. Here is the syntax, IF condition THEN               ...

Hello World - Getting Started with T24

Are you looking to develop great modules and local services for T24? This is the perfect place to start with. Let’s start from the basics. The core banking platform, T24 is developed with INFOBASIC code. This is the proprietary language of Temenos. T24 has the unique compiler to convert the BASIC code to object files with TAFc (Temenos Application Framework c) platform. An another flavour TAFj (Temenos Application Framework java), converts the BASIC to bytecode making it capable to run on any device with the Java runtime installed. The BASIC code remains same for both TAFc and TAFj Platform. Enough Intro! Let’s say hello to this world, How the syntax of this basic program looks like, PROGRAM program_name all the basic statements reside inside this block END Now, it is right time say hello, PROGRAM HELLO                 CRT “Hello World” END Yah, we did that. But, how to r...