Data types in c++

Preview:

Citation preview

DATA TYPES IN C++

DATA TYPES IN C++

BY:M.PAVANABDULLAHV.VENKAT RAMANAG.V.MANISH REDDY

CONTENTS

DATA TYPEBUILT IN TYPEUSER DEFINED TYPEDERIVED TYPE

DATA TYPE

A data type is a classification that specifies the type of value a variable can hold.

General syntax of declaration of data type is

data_type variable_name;Example: int a;

DATA TYPEC++ DATA TYPES

USER-DEFINED TYPE BUILT-IN TYPE DERIVED TYPE

INTEGRAL TYPE VOID FLOATING TYPE

STRUCTUREUNIONCLASS

ENUMERATION

ARRAYFUNCTIONPOINTER

int char float double

BUILT IN DATA TYPEC++ DATA TYPES

BUILT-IN TYPE

INTEGRAL TYPE VOID FLOATING TYPE

int char float double

BUILT IN DATA TYPE

INTEGRAL DATA TYPEINTEGER DATA TYPE:Keyword: intStorage space: two bytesRange of int: -32768 to 32767LONG INT

INTSHORT INT

SOME OF THE TYPES OF INT

BUILT IN DATA TYPE

INTEGRAL DATA TYPECHARACTER DATA TYPE:Keyword: charStorage space: 1 byteRange of char: -128 to 127

BUILT IN DATA TYPE

FLOATING DATA TYPEFLOAT DATA TYPE:Keyword: floatStorage space: 4 bytesRange of float: 3.4e-38 to 3.4e+38.

BUILT IN DATA TYPE

FLOATING DATA TYPEDOUBLE DATA TYPE:Keyword: doubleStorage space: 8 bytesRange of double: 1.7e-308 to 1.7e+308.

LONG DOUBLEDOUBLE

FLOATFLOATING TYPES

BUILT IN DATA TYPEVOID DATA TYPE

Type void was introduced in ansi c.Two normal use of void: To specify the return type of a function

when it is not returning any value. To indicate an empty argument list to a

function. Eg:- void function-name ( void )

USER DEFINED TYPEC++ DATA TYPES

USER-DEFINED TYPESTRUCTURE

UNIONCLASS

ENUMERATION

USER DEFINED TYPESTRUCTURES:Structures are used for grouping

together elements with dissimilar types.

The general syntax of a structure:- Struct name { Data_type member1; . . . . . };

USER DEFINED TYPE

Unions:Unions are conceptually similar to

structures as they allow us to group together dissimilar type elements inside a single unit.

The size of union is equal to the size of its largest member element.

USER DEFINED TYPECLASSES:The entire set of data and code of an

object can be made a user-defined data type with the help of a classes

Once a class has been defined, we can create any number of objects belonging to that class.

Example: fruit mango;Will create an object mango belonging to

the class fruit.

USER DEFINED TYPEENUMERATED DATA TYPE:An enumerated data type is another user

defined data type which provides a way for attaching numbers to names.

General syntax of enumerated data type is:-

enum identifier { Value1,valu2,………….,Valuen };

DERIVED TYPEC++ DATA TYPES

DERIVED TYPE

ARRAYFUNCTIONPOINTER

DERIVED TYPEARRAYS:An array is a fixed sequence collection of

elements of same data type that share a common name.

General syntax to declare is data_type name[size];General syntax to initialize is for(i=0;i<=10;i++) cin>>a[i];

DERIVED TYPEFUNCTIONS:  A function is a group of statements that

together perform a task.Every c++ program has at least one

function, which is main(). void main(){ Statements;}

DERIVED TYPEPOINTERS:A pointer is a variable that holds a

memory address.General syntax to declare pointer is:- Data_type *pointer_name;Example: int *p;

SUMMARYStructures are used for grouping together

elements with dissimilar types.Unions are conceptually similar to

structures as they allow us to group together dissimilar type elements inside a single unit.

Once a class has been defined, we can create any number of objects belonging to that class.

An enumerated data type is another user defined data type which provides a way for attaching numbers to names.

SUMMARY

An array is a fixed sequence collection of elements of same data type that share a common name.

A function is a group of statements that together perform a task.

A pointer is a variable that holds a memory address.

THANK YOU

Recommended