Explain sequence, selection and iteration as used in computer programming; outline the benefits of having a variety of data types available to the programmer.

Authors Avatar

Data Types

Task Brief

  • As Gary is fascinated about computer software, he would also like you (a) to explain sequence, selection and iteration as used in computer programming; (b) outline the benefits of having a variety of data types available to the programmer.

Contents

Introduction

This report will seek to address what data types are available to use in creating programming variables and on what basis they are used. I will also seek to address the advantages of selectively using different data types, and why different data types exist.

This report will discuss seven data types I consider to be the most important for the creation of a memory-efficient program, and these fall under three categories:

  • Number types
  • Character types
  • Logical type

Number Types

These variable types form the very foundation of a programming language. With these, we can calculate values and actually compute data. Depending on the types of number data being used, there are two kinds of number types we can use: whole / integer number and floating point / decimal number.

Whole numbers we use when we don’t require calculations to be too precise, such as scientific equations, so we need to make sure of this before we publish the program. Depending on how large we want our integers to go up to, or how efficient we want to be with our program’s RAM use, we can choose to use bytes, integers, or longs (otherwise called long integers). Bytes have a range of 256 units, whereas long integers have a range of 4,294,967,296 units. If we want to be able to use minus numbers, we also have to be aware that bytes will not be able to support these. (Mark Fishpool, 2011) In this comparison, bytes are less useful, but also happen to be two to four times as efficient when it comes to the amount of reserved space it creates in memory.

Join now!

Below is a table of these three integer types with their ranges and size in bytes:

Floating point / decimal integers, although requiring more reserved space in RAM than normal integers, can be more precise. They are called floating points because the decimal is not fixed, and can be moved around. (Wikipedia, 2011) Depending on how precise our numbers are required to be and how many decimal points we need to go to, we can choose either a single precision type or double precision type, abbreviated to single and double respectively. A double point variable of course requires double ...

This is a preview of the whole essay