A variable in programming: its types and usage Essay
A variable in programming: its types and usage, 502 words essay example
Essay Topic: time, group, example, unique
A variable in programming contains a quantity of information and the variable is known as a value. Variables will name data in a program so that the variable that is stored in the program can be called upon later. You would write a variable and then store information inside the variable and then you would be able to call that variable. Since the name and content are not together the name and content can both called upon on their own. The assignment statement is used for giving values to variables. The assignment operator can also store string values to string variables.
The memory layout for C programs is text segment, initialized data segment, uninitialized data segment, stack and heap. The text segment is a section in a program that contains executable instructions. The placement of the text segment can be placed below the heap or stack so that there will not be any overwrites. The initialized data segment contains global variables and static variables and the initialized segment is not read only due to the variables that remain can be different up to the running time point. The uninitialized data segment is initialized before the program starts executing and the uninitialized data segment contains the global and static variables that are set to zero. The heap contains an area of dynamic memory allocation and the heap area will start at the uninitialized data segment and the heap will grow from there into larger addresses. The stack goes by LIFO(last in first out) and is located in the high parts of memory.
In COBOL the data layouts are, redefined clauses, usage clause, rename clause and copybook. The redefine clause is used if you are trying to access one or more data items at the same time, then the same storage can be used for another data item. The rename clause does exactly what its name is and that is giving different names to existing data items and also used to regroup data names. The usage clause is used to specify how a data item is to be stored in the computer's memory. Every variable declared in a COBOL program has a USAGE clause even when no explicit clause is specified.(Coughlan) The level numbers are unique in COBOL and what the level numbers allow the programmer to do is specify the level of data in a record. The first level is used for elementary items and group items. The 1st level through the 49th is the group or elementary items, the 66th are the renames clause the 77th are the independency elementary data items and the 88th are the condition names. Elementary level items cannot be subdivisions and themselves cannot subdivide them. Level 66 is only used for rename clauses. Level 77 is used for items in the working storage and linkage sections. Below is an example of the 88th level known as condition names. The conditions are vowel, consonant, digit and valid character. Then after these names are the values that they hold.