<< Chapter < Page Chapter >> Page >
An introduction to data types within the C++ programming language.

General discussion

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 in various ways such as adding them up or sorting them. This data comes in different forms. Examples include: yourname 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 understanding how to design and code programs in centered in understanding the types of data that 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." Behrouz A. Forouzan and Richard F. Gilberg, Computer Science A Structured Approach using C++ Second Edition (United States of America: Thompson – Brooks/Cole, 2004) 33. 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

Placing some of the above into a summary table, we get:

Family Data Type Reserved Word Represents Standard Type
Nothing Null or nothing void No data Yes
Integer Boolean bool Logical true and false Yes
Integer Character char Single characters Yes
Integer Integer int Whole numbers Yes
Floating Point Floating Point float Fractional numbers Yes
Complex String string A sequence (sting them along) of characters No
Complex Array N/A A collection of elements of the same data type No
Complex Pointer N/A A value that points to a location (an address) within the data area No

The five standard data types usually exist in most programming languages and act or behave similarly from language to language. Most courses of study for a programming course or language will explain the standard data types first. After they are learned, the complex data types are introduced.

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.

Definitions

data type
Defines a set of values and a set of operations that can be applied on those values.
data type families
1) Nothing 2) Integer 3) Floating-Point 4) Complex
domain
The set of allowed values for a data type.
integer
A data type representing whole numbers.
floating point
A data type representing numbers with fractional parts.

Questions & Answers

how to create a software using Android phone
Wiseman Reply
how
basra
what is the difference between C and C++.
Yan Reply
what is software
Sami Reply
software is a instructions like programs
Shambhu
what is the difference between C and C++.
Yan
yes, how?
Hayder
what is software engineering
Ahmad
software engineering is a the branch of computer science deals with the design,development, testing and maintenance of software applications.
Hayder
who is best bw software engineering and cyber security
Ahmad
Both software engineering and cybersecurity offer exciting career prospects, but your choice ultimately depends on your interests and skills. If you enjoy problem-solving, programming, and designing software syste
Hayder
what's software processes
Ntege Reply
I haven't started reading yet. by device (hardware) or for improving design Lol? Here. Requirement, Design, Implementation, Verification, Maintenance.
Vernon
I can give you a more valid answer by 5:00 By the way gm.
Vernon
it is all about designing,developing, testing, implementing and maintaining of software systems.
Ehenew
hello assalamualaikum
Sami
My name M Sami I m 2nd year student
Sami
what is the specific IDE for flutter programs?
Mwami Reply
jegudgdtgd my Name my Name is M and I have been talking about iey my papa john's university of washington post I tagged I will be in
Mwaqas Reply
yes
usman
how disign photo
atul Reply
hlo
Navya
hi
Michael
yes
Subhan
Show the necessary steps with description in resource monitoring process (CPU,memory,disk and network)
samuel Reply
What is software engineering
Tafadzwa Reply
Software engineering is a branch of computer science directed to writing programs to develop Softwares that can drive or enable the functionality of some hardwares like phone , automobile and others
kelvin
if any requirement engineer is gathering requirements from client and after getting he/she Analyze them this process is called
Alqa Reply
The following text is encoded in base 64. Ik5ldmVyIHRydXN0IGEgY29tcHV0ZXIgeW91IGNhbid0IHRocm93IG91dCBhIHdpbmRvdyIgLSBTdGV2ZSBXb3puaWFr Decode it, and paste the decoded text here
Julian Reply
what to do you mean
Vincent
hello
ALI
how are you ?
ALI
What is the command to list the contents of a directory in Unix and Unix-like operating systems
George Reply
how can i make my own software free of cost
Faizan Reply
like how
usman
hi
Hayder
The name of the author of our software engineering book is Ian Sommerville.
Doha Reply
what is software
Sampson Reply
the set of intruction given to the computer to perform a task
Noor
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Programming fundamentals - a modular structured approach using c++. OpenStax CNX. Jan 10, 2013 Download for free at http://cnx.org/content/col10621/1.22
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Programming fundamentals - a modular structured approach using c++' conversation and receive update notifications?

Ask