Reality. Reinvented.
● it is one of the derived datatype.
● Array is a collection of similar elements which are in a
contiguous memory location.
● when no: of data increases it’s difficult to manage.
Syntax:
datatype var_name[ no ele ];
eg: int arr[5];
char chr[20];
● for accessing elements of array we need to use [ ]
index operator
● index start with ‘0’ .
● initial value of array is garbage values.
scan and print array:
● instead of printing each elements we can use loop
concepts.
scaning :
for(int i=0; i<ele; i++)
{
// scanf(“%d”,&a[i]);
printf(“%d”,a[i]);
}
initialization of data:
● int a[5];
● int a[ ];
● int a[5] = 10,20,30,40,50;
● int a[5] = 10,20;
● int a[5] = 10,20,30,40,50,60,70;
● int a[ ] = 10,20,30,40,50;
programs:
1. WAP to reverse print an array?
2. WAP to reverse element of array?
3. WAP to check palindrom number are present or not in
a [Link] present print the number
4. WAP to find largest in an array
sorting of an array:
● Bubble sort:
○ compare with ‘0’th and ‘i’ th index element.
○
● selection sort:
○ fix one index and other index values compare with
others.
● Array and pointer:
○ Array name represents base address of array
○ a+i and &a+i
○ Array treated as constant pointer.
int *const p;
p++; →error
● copying an array:
● character and integer pointer on array
THANK YOU
Contact:
Fasil KV
9497042007
fasil@[Link]
[Link]