Declaration is the process of reserving a portion in main memory (RAM) for storing the contents of a variable. In many high-level computer languages, the programmer must write a specific statement to reserve that portion in the RAM. In most cases, they even need to specify the variable type so that the compiler or the interpreter knows exactly how much space to reserve.

Here are some examples showing how variables are declared in different high-level computer languages.

Declaration Statement High-level Computer Language
Dim sum as Integer Visual Basic
int sum; Java, C#, C++, and many more
sum: Integer; Pascal, Delphi
var sum; Javascript

Leave a Reply

Your email address will not be published. Required fields are marked *

This article is taken from a book of mine. If you enjoyed it, please visit my author's page inand check out all of my books!