ARRAY IN C

Best Blogger Tips
BREIF ABOUT ARRAY

ARRAY: is a collection of similar data type elements.
 Eg: 1) int b[10] means all the elements in array have similar data type i.e int
 2) float a[5] all the elements in array have same data type i.e float

DATA TYPE: means what type of value you can store in a variable.

VARIABLE: is named memory area that can hold the items.

DIFFERENT TYPES OF DATA TYPES:

1) INT means in this data type integer values are stored in variables.
Eg: int a[ 10,20,30,40,50]

2)FLOAT means in this data type only decimal values are allowed to store in variable.
Eg: float b[1.2, 1.5, 8.9,5.0, 4.0]

*In this example there is important point that in float data type we assign integer value to variable b. But in case of int data type we can not assign decimal values to variable.

3) CHAR: is a character type data type.
Eg: char G[a,b,c,d,e ]

4) STRING: is a data type that is collection of characters.
Eg: string A[shubham, visitors, pageviews]

* ALL THE ABOVE FOUR DATA TYPES ARE PRIMITIVE DATA TYPES.

*NON-PRIMITVE DATA TYPES:


1) ARRAY:is a collection of similar data type elements.
>array is reprensented by index number.
>index number vary from 0 to upto one less than size of array.

ARRAY DECLARATION:
1) Before the variable name data type is defined.
2) size of array is shown in pair of suscripts.
Eg: int var[5]

2)STRUCTURE: is a collection of different data type elements.
Eg:struct structure
{
int a[5];
float b[10];
char c;
};

STRUCTURE DECLARATION:
1)
>struct: is a key word used in structure.
Eg: struct student,
struct employee
2)body of structure enclosed with a pair of braces and ends with a semi colon.
Eg:
Eg:struct student
{
int age;
float marks[10];
char name;
};
> we can access elements in structure with dot operator.

3) FUNCTION

Kindly Share The Love »»

Save on Delicious

No comments:

Post a Comment