DATA HANDLING (Avinash and mayank)

Category: Education

Presentation Description

it is based on data types from class XI Science....i hope you will like it


Presentation Transcript



Basic Data Types:

Basic Data Types C++ Data Types User-defined Type Built-in Type Derived Type Integral Type Void Floating Type structure union class enumeration array function pointer reference int char float double

Two Classifications of Data Types:

Built-in data types Fundamental data types ( int, char, double, float, void, pointer ) Derived data types (array, string, structure) Programmer-defined data types Structure Union Enumeration Two Classifications of Data Types

PowerPoint Presentation:

Only really four basic types: char int (short, long, long long, unsigned) float double Size of these types on CLEAR machines: Sizes of these types vary from one machine to another! Type Size (bytes) char 1 int 4 short 2 long 8 long long 8 float 4 double 8 Data types in C++ FUNDAMENTAL DATA TYPES

Fundamental Data Types:

Fundamental Data Types void – used to denote the type with no values int – used to denote an integer type char – used to denote a character type float, double – used to denote a floating point type int *, float *, char * – used to denote a pointer type, which is a memory address type

Characters (char):

Characters can store any member of the C++ implementation’s basic character set. Roman alphabet, punctuation, digits, and other symbols: Can encode within one byte (256 symbols) ASCII encoding ( man ASCII for details) In C: 6 Characters (char) char a_char = ’a’; char newline_char = ’\n’; char tab_char = ’\t’; char backslash_char = ’\\’;


Integers are whole number such as 5,39,-1917. Standard low-level solution: Limit number range and precision Usually sufficient Potential source of bugs Signed and unsigned variants unsigned modifier can be used with any sized integer (short, long, or long long) 7 Integers


FLOAT DATA TYPES A Number having fractional part is a floating-point number. The decimal points signals that it is a floating-point number not integer Binary version of scientific notation 1.001101110 × 2 5 = 100110.1110 = 32 + 4 + 2 + 1 / 2 + 1 / 4 + 1 / 8 = 38.875 -1.011 × 2 -3 = -.001011 = - ( 1 / 8 + 1 / 32 + 1 / 64 ) = -.171875 binary point

PowerPoint Presentation:

DOUBLE DATA TYPES The data types double is also used for handling floating-point numbers. But it is treated as a distinct data type because, it occupies as much memory as type float, and store floating-point numbers with much larger range and precision. VOID DATA TYPES The void type specifies an empty set of values. It is used as the return type for functions that do not return a object of type void may be declared.

Derived Data Types:

Derived Data Types Derived data types are those that are defined in terms of other data types, called base types. Derived types may have attributes, and may have element or mixed content There are five types of derived data types Arrays Structure Pointer References Constants

PowerPoint Presentation:

ARRAYS C++ Arrays are the data structures which can be used to store consecutive values of the same data types . C++ Arrays can be declared for all c++ data types viz., int, float, double, char, struct, char etc., All the values are stored in consecutive memory locations. The values can be accessed by using the position of the stored value. CONSTANT The const keyword specifies that a variable's value is constant and tells the compiler to prevent the programmer from modifying it.

PowerPoint Presentation:

REFERENCE A reference is an alias or an alternative name for an object. All operations applied to a reference act on the object to which the reference refers. The address of a reference is the address of the aliased object. Pointer A pointer in C++ is said to "point to" the memory address that is stored in it. Also, when defining a C++ pointer variable, we must specify the type of variable to which it is pointing. For example, to define a pointer, which will store a memory address at which exists an int, we can do the following:

PowerPoint Presentation:

. FUNCTIONS Functions are building blocks of the programs. They make the programs more modular and easy to read and manage. All C++ programs must contain the function main( ). The execution of the program starts from the function main( ). A C++ program can contain any number of functions according to the needs

PowerPoint Presentation:

User defined derived data types

PowerPoint Presentation:

UNION A union is a user-defined data or class type that, at any given time, contains only one object from its list of members (although that object can be an array or a class type). Structure Structure is a collection of variables under a single name. Variables can be of any type: int, float, char etc. The main difference between structure and array is that arrays are collections of the same data type and structure is a collection of variables under a single name


Enumerations enumeration – set of named elements Values are usually ordered, can compare enum weekday {sun,mon,tue,wed,thu,fri,sat} if (myVarToday > mon) { . . . } Advantages More readable code Compiler can catch some errors Is sun==0 and mon==1 ? C/C++: yes; Pascal: no Can also choose ordering in C enum weekday {mon=0,tue=1,wed=2…} 16

Data -- Variables :

Data -- Variables CS 105 Fall 2005 Variables are memory locations that hold data that can change during the execution of the program. The properties of an object are all variables that can change. For example, Enabled = True can be changed to Enabled = False

Named Constants:

Named Constants Programming with Microsoft Visual Basic .NET, Second Edition 18 A memory location whose contents cannot be changed while the program is running You create a named constant using the Const statement Syntax: Const constantname [As data type ] = expression Example: Const PI As Double = 3.141593

PowerPoint Presentation:


authorStream Live Help