Gagan Deep: Arrays
Gagan Deep: Arrays
Gagan Deep
Rozy Computech Services
3rd Gate, K.U., Kurukshetra-136119
M- 9416011599
Email [email protected]
Arrays
Array is a linear list of homogenous elements,
#include <stdio.h>
void main()
{ int marks[5],i;
printf(Input of Array marks);
for (i=0; i<5; i++)
scanf(%d, &marks[i]);
printf(Output of Array marks);
for (i=0; i<5; i++)
printf(marks[%d] = %d , i,
marks[i]);
Do Yourself
Understand Algorithms and do the programming of
Following
1. Deletion from an Array
2. Merging
3. Insertion Sort
4. Selection Sort
5. Merge Sort
6. Radix Sort
7. Second Largest Element in the List
8. Delete the item from the list
9. Prime Numbers using Sieves Algorithm
MultiDimensional Array
arrays are defined in much
the same manner as one dimensional arrays,
except that a separate square brackets
required in each subscript.
Thus, a two dimensional array will require
two pairs of square bracket,
aij -> a[i][j] -> a[rows][coulmn]
a three dimensional array will require three
pairs of square brackets, and so on
aijk -> a[i][j][k] -> a[page][rows]
[coulmn]
Multidimensional
MultiDimensional Array
In general terms, a multidimensional array
2 Dimensional Array
2 dimensional array can be expressed as
col1 col2
col3
Row 1 X[0][0] X[0][1]
Row 2 X[1][0] X[1][1]
Row 3
Row n
X[n-1][0]
X[n-1][1]
coln
X[0][n1]
X[1][n-1]
X[n-1][n1]
for(i=0;i<3;++i)
for(j=0;j<3;++j)
c[i][j]=a[i][j]+b[i][j];
printf("\nSum Of Matrix:");
for(i=0;i<3;++i)
{
for(j=0;j<3;++j)
printf("Enter the elements of
printf("%.1f\t",c[i][j]);
2nd matrix\n");
for(i=0;i<3;++i)
printf("\n"); }
for(j=0;j<3;++j)
}
scanf("%f",&b[i][j]);
THANKS!
If you have any queries you
can contact me at :
[email protected]