0% found this document useful (0 votes)
8 views

Data-Types-and-Data-Structure1

The document discusses the evolution of data organization from manual record-keeping to modern computer programming, highlighting the importance of data types and structures. It explains the concepts of constants, named constants, and variables, emphasizing how they are used in programming to manage data efficiently. Variables, in particular, allow for flexibility in programs by representing temporary values that can change during execution.

Uploaded by

Eyaa Raine
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Data-Types-and-Data-Structure1

The document discusses the evolution of data organization from manual record-keeping to modern computer programming, highlighting the importance of data types and structures. It explains the concepts of constants, named constants, and variables, emphasizing how they are used in programming to manage data efficiently. Variables, in particular, allow for flexibility in programs by representing temporary values that can change during execution.

Uploaded by

Eyaa Raine
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Data Types and Data Structures

Like most clerks during the 19th century, Dickens's Bob Cratchitt was forced to do
his data organization by hand. Everything was written down in the record books
and organized in such a manner that everything was labeled neatly and properly.
Nowadays, data manipulation has gone a long way from being etched on to paper
by quill and inkpot. Computer programs have made our lives easier in terms of
organizing and accessing large amounts of different types of data.
Remember from our previous lessons that a program is a set of instructions that
tells a computer what to do. However, a program can't be just all commands — it
also needs data to manipulate or work on in order to produce an output. Because
of this, programming languages need mechanisms for declaring, storing, and
handling different types of data. Data could be anything from numerical figures to
dates to names to bank transaction records.
For the purposes of this lesson, we will concentrate only on the more common
data types and data structures that you are likely to encounter or use in the
course of the succeeding lessons.

Constants and Variables


Literal Constant
When a set of instructions is given to a computer, the data that need to be
processed are normally included in the instruction. For example, to compute for
the area of a triangle with a base of 10cm and height of 15cm, the instruction
would be: multiply 10 by 15, then divide the product by 2.

Named Constant
Sometimes, it is difficult for a programmer to keep on typing a value that is used
several times in the program. Let's say that the pi value 3, 1416 is used for
computing the areas of 10 circles with different diameters. Instead of typing
"3.1416" 10 times, the value is substituted by the label or identifier pi. The term
"pi" is therefore interpreted by the computer as a named constant that will
always represent the value 3, 1416.
NOTE
A declaration needs to be made in the program in order to associate the term "pi"
with the fixed value 3.1416. Essentially, declaring a label to have a specific value
means that any use of that label automatically refers to the given literal value. In
case there is a need to use a different value for pi, either to increase or decrease
the number of decimal places, only the values of the declaration need to be
changed.

Variables
Not all declarations result in a label becoming permanently associated with a
literal constant. Whenever declarations are made in a program, the actual action
done by the computer is to allocate or assign a storage location in memory that
will be referred to throughout the program by the declared label or identifier.
There are usually specific rules or conventions that we need to follow when
naming identifiers. This may vary depending on the programming language

If a declared label or identifier is not fixed or permanently associated to a literal


value' then that declaration label or identifier is classified as a variable. The
variable acts as a symbol that your computer program equates to a temporary
value stored in a memory location. It accepts different values as the program
runs. Because of this, variables play an important role in computer programming.
They allow programmers to write flexible programs that can handle changing
data. Rather than encode the actual values directly into a program, a programmer
uses variables to represent the data. When the program is executed, the variables
are replaced with actual values. This makes it possible for the same program to
process different sets of data without the need to be rewritten.

You might also like