Professional Documents
Culture Documents
8.0 Session Eight: Data Structures 8.1 Session Objectives
8.0 Session Eight: Data Structures 8.1 Session Objectives
8.0 Session Eight: Data Structures 8.1 Session Objectives
(ii) Dynamic data structures: Their size is changing all time in the main memory i.e not
fixed
Examples:
i. Stack: is a linear list in which insertion and deletions can take place only
at one end called top( LIFO system)
ii. Queue: : is a linear list in which deletions can take place at one end of
the list (front) and insertion can only take only at the other end of the
list(rear).
(ii) Searching: Finding the location of the record with a given key
value called Primary key.
An array is a data structure in which a collection of data items of the same data type are stored.
Characteristic of Arrays
Data items of the same data type are stored.
Items are referenced by index
Multi-dimensional array has several rows and columns
ARRAY DECLARATION
1-Dimension array :
Int score[6]; / * Array called score having 6 elements of integer type */
2- Dimension array:
Int score[6][4]; / * Array called Table having 6 rows and 4 columns of integer type */
3- Dimension array:
score
16 12 6 4 7 20
ARRAY DECLARATION
Develop a C program to read six integer values into an Array called Score then display the
numbers and the sum.
#include<stdio.h>
Void main(void)
{
Int score[6],sum, i ;
i=0;
Sum=0;
For(i=0; i<5; ++i)
{
Printf(“Enter a number”); Reading six elements in an array called score and
Scanf(“%i”,&score[i]); calculating their sum.
Sum=sum+score[i];
}
For(i=0; i<5; ++i)
{ Printing the six numbers.
Printf(“%i”,score[i]);
}