Data types in c++
-
Upload
manish-reddy -
Category
Education
-
view
73 -
download
1
Transcript of Data types in c++
![Page 1: Data types in c++](https://reader033.fdocuments.net/reader033/viewer/2022042906/58ac441f1a28ab99028b5013/html5/thumbnails/1.jpg)
DATA TYPES IN C++
![Page 2: Data types in c++](https://reader033.fdocuments.net/reader033/viewer/2022042906/58ac441f1a28ab99028b5013/html5/thumbnails/2.jpg)
DATA TYPES IN C++
BY:M.PAVANABDULLAHV.VENKAT RAMANAG.V.MANISH REDDY
![Page 3: Data types in c++](https://reader033.fdocuments.net/reader033/viewer/2022042906/58ac441f1a28ab99028b5013/html5/thumbnails/3.jpg)
CONTENTS
DATA TYPEBUILT IN TYPEUSER DEFINED TYPEDERIVED TYPE
![Page 4: Data types in c++](https://reader033.fdocuments.net/reader033/viewer/2022042906/58ac441f1a28ab99028b5013/html5/thumbnails/4.jpg)
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++](https://reader033.fdocuments.net/reader033/viewer/2022042906/58ac441f1a28ab99028b5013/html5/thumbnails/5.jpg)
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++](https://reader033.fdocuments.net/reader033/viewer/2022042906/58ac441f1a28ab99028b5013/html5/thumbnails/6.jpg)
BUILT IN DATA TYPEC++ DATA TYPES
BUILT-IN TYPE
INTEGRAL TYPE VOID FLOATING TYPE
int char float double
![Page 7: Data types in c++](https://reader033.fdocuments.net/reader033/viewer/2022042906/58ac441f1a28ab99028b5013/html5/thumbnails/7.jpg)
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++](https://reader033.fdocuments.net/reader033/viewer/2022042906/58ac441f1a28ab99028b5013/html5/thumbnails/8.jpg)
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++](https://reader033.fdocuments.net/reader033/viewer/2022042906/58ac441f1a28ab99028b5013/html5/thumbnails/9.jpg)
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++](https://reader033.fdocuments.net/reader033/viewer/2022042906/58ac441f1a28ab99028b5013/html5/thumbnails/10.jpg)
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++](https://reader033.fdocuments.net/reader033/viewer/2022042906/58ac441f1a28ab99028b5013/html5/thumbnails/11.jpg)
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++](https://reader033.fdocuments.net/reader033/viewer/2022042906/58ac441f1a28ab99028b5013/html5/thumbnails/12.jpg)
USER DEFINED TYPEC++ DATA TYPES
USER-DEFINED TYPESTRUCTURE
UNIONCLASS
ENUMERATION
![Page 13: Data types in c++](https://reader033.fdocuments.net/reader033/viewer/2022042906/58ac441f1a28ab99028b5013/html5/thumbnails/13.jpg)
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++](https://reader033.fdocuments.net/reader033/viewer/2022042906/58ac441f1a28ab99028b5013/html5/thumbnails/14.jpg)
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++](https://reader033.fdocuments.net/reader033/viewer/2022042906/58ac441f1a28ab99028b5013/html5/thumbnails/15.jpg)
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++](https://reader033.fdocuments.net/reader033/viewer/2022042906/58ac441f1a28ab99028b5013/html5/thumbnails/16.jpg)
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++](https://reader033.fdocuments.net/reader033/viewer/2022042906/58ac441f1a28ab99028b5013/html5/thumbnails/17.jpg)
DERIVED TYPEC++ DATA TYPES
DERIVED TYPE
ARRAYFUNCTIONPOINTER
![Page 18: Data types in c++](https://reader033.fdocuments.net/reader033/viewer/2022042906/58ac441f1a28ab99028b5013/html5/thumbnails/18.jpg)
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++](https://reader033.fdocuments.net/reader033/viewer/2022042906/58ac441f1a28ab99028b5013/html5/thumbnails/19.jpg)
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++](https://reader033.fdocuments.net/reader033/viewer/2022042906/58ac441f1a28ab99028b5013/html5/thumbnails/20.jpg)
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++](https://reader033.fdocuments.net/reader033/viewer/2022042906/58ac441f1a28ab99028b5013/html5/thumbnails/21.jpg)
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++](https://reader033.fdocuments.net/reader033/viewer/2022042906/58ac441f1a28ab99028b5013/html5/thumbnails/22.jpg)
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++](https://reader033.fdocuments.net/reader033/viewer/2022042906/58ac441f1a28ab99028b5013/html5/thumbnails/23.jpg)
THANK YOU