Cs112 - Programming Fundamental: Lecture # 27 - Arrays in C Syed Shahrooz Shamim
Cs112 - Programming Fundamental: Lecture # 27 - Arrays in C Syed Shahrooz Shamim
Lecture # 27 – Arrays in C
Syed Shahrooz Shamim
Junior Lecturer,
CS Department, UIT
What is Array?
• An array is a fixed-size sequential
collection of elements of same data types
that share a common name.
• It is simply a group of data types.
• An array is a derived data type.
• An array is used to represent a list of
numbers , or a list of names.
Example of Arrays
1. List of employees in an organization.
2. Test scores of a class of students.
3. List of customers and their telephone numbers.
4. List of students in the college.
– For Example, to represent 100 students in
college, can be written as
student [100]
– Here student is a array name and [100] is
called index or subscript.
Types of Arrays
1. One-dimensional arrays
2. Two-dimensional arrays
3. Multidimensional arrays
One-Dimensional Arrays
• A variable which represent the list of items using
only one index (subscript) is called one-
dimensional array.
Num[2] =data3
Data Type is the type of elements to be stored in the array
Num[3] =data4
Num[9] =data10
Accessing One Dimensional Array Elements
#<Include<stdio.h>
#include<conio.h> OUTPUT
Arrray declaration
Void main()
{ Enter the array
Int a[10];
Clrscr(); 1 2 3 4from
Taking values 5 6 7user
8 9 10
Printf (“enter the array”);
For (i=0;i<10;i++)
{ Entered array is
Scanf(“%d”,&a[i]); 1
} Printing the values
2
Printf(“the entered array is”); 3
For(i=0;i<10;i++) 4
{ 5
printf(“%d”,a[i]);} 6
} 7
getch(); 8
} 9
10
9/24/2019
Example