Tuesday, August 11, 2009

Basic data types

Computer programs produces results by manipulating data. A programming language must have a way of representing and handling data. For this reason there are:
- Basic data types for representing data
- Reserved words and operators for handling it.

In general, objects can be grouped into types according to their properties, i.e. the same operations can be performed on them.

Basic data types are built in into the language. The language recognizes them automatically. They usually require only a little if any non hardware support for their implementation.

All data has a type and only values of the same type can usually operate together. First, a quick look at some basic data types in C++ called arithmetic types.

Normal arithmetic operations can be performed on these types. In C++ these types are:

-int for integer (whole numbers and their negatives) i.e. -2, 123456.
-double (float) for real numbers, i.e. 3.1425, 1.4142
-char for character data (letters, digits, symbols, punctuation) i.e. 'a', '\n'

In fact character data is stored inc computers as numeric codings in C++.

The type for a sequence of characters in C++ is called string. string is a basic type for all practical purposes, but in reality it is more complex.


Previous post

Next post




No comments:

Post a Comment