DATA HANDLING
Data - Data is like a raw facts and statistics collected together for reference or analysis and useful information is derived from data only.
" Data Types are means to be identify the types of data and associate operations of handling it. "
There are two types of data:
1) Fundamental Data Type
2) Derived Data Type
Fundamental Data type -
- These are not composed of other data types.
- It is also called Primary Data type
like-
1- Integer - the number without fractional part or decimal part is called Integer.
2- Characters - any single character enclosed in single quote.
3- Float - the number with frictional part or decimal part is called float.
4- Double
5- Void - It specifies return types of a function or non-returning function.
Data Type Modifiers -
These are the keywords which are used to modify the storing capacity of the variables.
like-
1- singed
2- unsigned
3- short
4- long
Note- Unsigned integer can store the range of larger number than signed integer and long integer even larger range than unsigned integer.
Derived Data Type -
-These are the data type which are derived from fundamental data type or basic data type
-It is also called secondary Data type
like-
1- Array -
" It is a set of variables of same data type referred under a common name "
0r
" It is a collection of homogeneous elements "
Eg- int a [10]; // declaration of array
2- Function -
" It is a small program which is used to perform a specific task. It may be return a value. "
Eg- // functions to find cube
int cube (float x)
{
return (x*x*x);
}
3- Pointer -
" It is a variable which contains/holds the address of another variable "
Eg- int x; //declare variable x
int *ip; //declare integer pointer
ip=&x; //& (ampersand) is used to give address of the location.
cout>>x; // display value of x, output is same as *ip
cout>>*ip; // display value of *ip ,output is same as x
4- References -
" It is an alternative name for a variable . It provide alis for a previously defined variable. "
0r
" It is the another name given to the variable "
Eg - int sum = 100; // initialize and declare variable sum
int &total = sum; // total is a reference variable and assigning sum value to it.
cout<<total; // display value of total and it is same as sum.
cout<<sum; // display value of sum and it is same as total.
5- Constants -
" It is the variable Who's value does not change "
and the keyword is used " const " before declaration variable.Eg- const int strength = 60; // initialize and declare constant variable "strength"
Absent = strength - present ;
6- Class -
" It is a user defined Derived data type. It represents a group of similar object. It contains variables and function. "
Eg -
class student
{
int roll_no;
char name[30];
float percent;
public: // it is access modifiers used for security (we will talk later)
void get(); // function to get data
void put(); // function is used to set data
} ;
7- Structure -
" It is the set relative variables. Variables may be same or different data types. "
Eg -
struct student // struct is a keyword used for declaration of structure
{
int roll_no;
char name[30];
float percent;
} ;
Note- 2 byte used in int + 30 byte used in name + 6 byte in float =total 36 byte memory occupied.
8- Union -
" It is a user defined derived data type . it is similar to structure ." The difference is that in case of structure memory is given to all the variables member whereas in Union memory is given to the largest variable only and that memory shared by all the members. "
Eg -
union student // union is a keyword used for declaration of structure
{
int roll_no;
char name[30];
float percent;
} ;
Note- 30 byte used in name array is in all the data members present in union.
9- Enumeration -
" It is alternative method for naming integer constant. "
Eg- enum{x=2,y,z}
It means x=2 , y=3 and z=3; // It initialize the values in ascending order of +1.
Comments
Post a Comment