23
DATA TYPES IN C++

Data types in c++

Embed Size (px)

Citation preview

Page 1: Data types in c++

DATA TYPES IN C++

Page 2: Data types in c++

DATA TYPES IN C++

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

Page 3: Data types in c++

CONTENTS

DATA TYPEBUILT IN TYPEUSER DEFINED TYPEDERIVED TYPE

Page 4: Data types in c++

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;

Page 5: Data types in c++

DATA TYPEC++ DATA TYPES

USER-DEFINED TYPE BUILT-IN TYPE DERIVED TYPE

INTEGRAL TYPE VOID FLOATING TYPE

STRUCTUREUNIONCLASS

ENUMERATION

ARRAYFUNCTIONPOINTER

int char float double

Page 6: Data types in c++

BUILT IN DATA TYPEC++ DATA TYPES

BUILT-IN TYPE

INTEGRAL TYPE VOID FLOATING TYPE

int char float double

Page 7: Data types in c++

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

Page 8: Data types in c++

BUILT IN DATA TYPE

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

Page 9: Data types in c++

BUILT IN DATA TYPE

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

Page 10: Data types in c++

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

Page 11: Data types in c++

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 )

Page 12: Data types in c++

USER DEFINED TYPEC++ DATA TYPES

USER-DEFINED TYPESTRUCTURE

UNIONCLASS

ENUMERATION

Page 13: Data types in c++

USER DEFINED TYPESTRUCTURES:Structures are used for grouping

together elements with dissimilar types.

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

Page 14: Data types in c++

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.

Page 15: Data types in c++

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.

Page 16: Data types in c++

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 };

Page 17: Data types in c++

DERIVED TYPEC++ DATA TYPES

DERIVED TYPE

ARRAYFUNCTIONPOINTER

Page 18: Data types in c++

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];

Page 19: Data types in c++

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;}

Page 20: Data types in c++

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;

Page 21: Data types in c++

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.

Page 22: Data types in c++

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.

Page 23: Data types in c++

THANK YOU