Arrays
,Introduction
• Consider the task of reading and printing marks of 20 students
• This requires more variables
• Reading data and printing data to more variable is difficult These dis
• Difficult to process large amount of data can be ov
• Length of the program increases using a po
structure c
• Not a good programming style
int m1,m2,m3,m4,….m20;
scanf(“%d%d%d……….%d”,&m1,&m2,…….&m20);
printf(“m1=%d, m2=%d,……m20=%d”,m1,m2,…..m20);
, Array
• Array is a special data structure used in C language
• It is used to store, process and print large amount of data
• Definition:
Array is a collection of similar types of items stored sequentiall
one after the other in memory
• Example: Set of integers, set of characters, marks of all students,…
A[0] 10 B[0] B[1] B[2] B[3] B[4
Pictorial A[1] 20 Array of integers
1.5 9.3 2.3 5.8 0.4
representation of A[2] 30
array
A[3] 40
Array of floating poi
A[4] 50
,Introduction
• Consider the task of reading and printing marks of 20 students
• This requires more variables
• Reading data and printing data to more variable is difficult These dis
• Difficult to process large amount of data can be ov
• Length of the program increases using a po
structure c
• Not a good programming style
int m1,m2,m3,m4,….m20;
scanf(“%d%d%d……….%d”,&m1,&m2,…….&m20);
printf(“m1=%d, m2=%d,……m20=%d”,m1,m2,…..m20);
, Array
• Array is a special data structure used in C language
• It is used to store, process and print large amount of data
• Definition:
Array is a collection of similar types of items stored sequentiall
one after the other in memory
• Example: Set of integers, set of characters, marks of all students,…
A[0] 10 B[0] B[1] B[2] B[3] B[4
Pictorial A[1] 20 Array of integers
1.5 9.3 2.3 5.8 0.4
representation of A[2] 30
array
A[3] 40
Array of floating poi
A[4] 50