Introduction to C + +: 3 C + + Character Set and Basic Data Types

Doorsteptutor material for IAS/Mains/Optional Public-Administration is prepared by world's top subject experts: Get detailed illustrated notes covering entire syllabus: point-by-point for high retention.

3 C++ Character Set

• Character set is a set of valid characters that a language can recognized. A character represents any letter, digit or any other special character.

• The C++ has the following character set.

Basic Data Types

• Every program specifies a set of operations to be done on some data in a particular sequence.

• However, the data can be of many types such as a number, a character, Boolean value etc. C++ supports a large number of data types.

Integer Type (Int)

• An integer is an integral whole number without a decimal point.

• These numbers are used for counting. These numbers are used for counting.

• Normally an integer can hold numbers from -32768 to 32767.

• However, if the need be, a long integer (long int) can also be used to hold integers from -2, 147, 483, 648 to 2, 147, 483, 648.

Floating Point Type (Float)

• A floating-point number has a decimal point.

• Even if it has an integral value, it must include a decimal point at the end. These numbers are used for measuring quantities.

• Examples of valid floating-point numbers are:

• A float type data can be used to hold numbers from with six or seven digits of precision

• However, for more precision a double precision type (double) can be used to hold numbers from with about 15 digits of precision.

3 Character Type ((Char)

• It is a non-numeric data type consisting of single alphanumeric character. Examples of valid character types are: ‘A’, ‘9’, ‘P’, ‘8’, ‘&’.

• It may be noted here that 9 and ‘9’ are of different data types.

• The former is of type int and later of type char.

Developed by: