Data Types

Only available on StudyMode
  • Topic: Data type, Data types, Floating point
  • Pages : 7 (1808 words )
  • Download(s) : 146
  • Published : December 4, 2012
Open Document
Text Preview
LECTURE 1
DATA TYPES
Our interactions (inputs and outputs) of a program are treated in many languages as a stream of bytes. These bytes represent data that can be interpreted as representing values that we understand. Additionally, within a program we process this data that can be interpreted as representing values that we understand. Additionally, within a program we process this data in various way such as adding them up or sorting them. This data comes in different forms. Examples include: your name which is a string of characters; your age which is usually an integer; or the amount of money in your pocket which is usually a value measured in dollars and cents (something with a fractional part). A major part of understand how to design and code programs in centered in understanding the types of data we want to manipulate and how to manipulate that data. A type defines a set of values and a set of operations that can be applied on those values. The set of values for each type is known as the domain for that type. The four major families of data include: •Nothing

Integer
Floating-point
Complex
The C++ programming language identifies five data types as standard data types: •Void
Boolean
Character
Integer
Floating-point
The standard data types and the complex data types within C++ have a series of attributes, which include: •C++ Reserved or Key Word
Domain – the allowed values
Signage – do they allow negative numbers or only positive numbers •Meaning – i.e What do they represent
Rules of Definition – What special characters indicate the data type •Size – in terms of the number of bytes of storage used in the memory •Operations Allowed – i.e. Which operators can I use on the data type FamilyData TypeReserved WordRepresentsStandard Type

NothingNull or nothingvoidNo dataYes
IntegerBooleanboolLogical true and falseYes
IntegerCharactercharSingle charactersYes
IntegerIntegerintWhole numbersYes
Floating PointFloating PointfloatFractional numbersYes
ComplexStringstringA sequence (sting them along) of charactersNo ComplexArrayn/aA collection of elements of the same typeNo ComplexPointern/aA value that points to location (an address) within the data areaNo

The five standard data types usually exist in most programming languages and act or behave similarly from language to language. The Boolean, character and integer data types are identified as belonging to the Integer Family. These data types are all represented by integer numbers and thus act or behave similarly. Often Used Data Types

1.Integer Data Type
-The integer data type with its various modifiers that create different domains. -The integer family which also includes Boolean and character data types. The integer data type basically represents whole numbers (no fractional parts). The integer values jump from one value to another. It could be asked why not make all your numbers floating point. Which allow for fractional parts. The reason is twofold. First, some things in the real world are not fractional. A dog, even with only 3 legs, is still one (1) dog not ¾ of a dog. Second, integer data type is often used to control program flow by counting, thus the need for a data type that jumps from value to another. The integer data type has the same attributes and acts or behaves similarly in all programming languages. The most often used integer data type in C++ in the simple integer. C++ Reserved Wordint

RepresentWhole numbers (no fractional parts)
SizeUsually 4 bytes
Normal SignageSigned (negative and positive values)
Domain (Values Allowed)-2,147,483,648 to 2,147,483,648
C++ syntax ruleDo not start with a 0 (zero)
C++ syntax ruleNo decimal point

Within C++ there are various reserved words that can be used to modify the size or signage of an integer. They include: long, short, signed and unsigned. Signed is rarely used because integers are signed by default – you must specify...
tracking img