Tuesday 17 September 2013

C++ Data Types

Data types in C++:

In this post of shapes in C, we will discuss fifth C tutorial for beginners in which we will tell you about C++ Data types . The purpose of C++ program is to manipulate different data in solution of a problem. To manipulate data, we need to store our data somewhere. For that purpose, we have data types in C++. Data type is a set of values together with a set of operations.

In C++, data type consists of two things:


  • Range of data type.
  • Operations allowed on it.

C++ data types fall in three categories:


  • Simple
  • Structured
  • Pointer

For now, we are going to focus on simple data types.

Simple data types are the fundamental data types in C++. They further fall in three categories.

  • Integral
  • Floating point
  • Enumeration

c data types



Integral:


Integral data types are further classified in nine categories.

  • Char
  • Short
  • Int
  • Long
  • Bool
  • Unsigned Char
  • Unsigned short
  •  Unsigned int
  •  Unsigned long

Int Data type:


Below are the following rules for int data type.

  1. Positive integers don’t need a + sign in front of them.
  2. No commas are used within an integer.

Size:

     It has a size of 4 bytes.

Bool Data type:


It is a logical data type and it has only two values: true and false. Its purpose is to handle logical expressions.



Char Data type:


It is the smallest integral data type. It is used to represent characters. It can represent every key on your keyboard on the basis of ASCII and EBCDIC codes. ADCII has 128 values and EBCDIC has 256 values.



Floating point data types:


     Float:


It is used in C++ to represent any real number between -3.4E+38 and 3.4E+38. The memory allocated for it is 4 bytes.



    Double:


       It is used in C++ to represent any real number between -1.7E+308 and 1.7E+308. The memory allocated for it is 8 bytes.




Final words:


In this c tutorial for beginners of shapes in c, we have learnt about c data types, its size and range.These c programming tutorials will definitely help you out in your problems.

0 comments:

Post a Comment