Programming with C – Arrays- Lecture5

Array is a linear list of homogeneous elements, stored at successive memory locations in consecutive order.

C programming language provides a data structure called the array, that can store a fixed size sequential collection of elements of same data type.

An array is used to store a collection of data, but it is often more useful to think of an array as a collection of variables of the same type. For example, if your class strength is 50 then your roll numbers are rollnumber1, rollnumber2, rollnumber3 …… rollnumber50.

Instead of declaring individual variables, such as rollnumber1, …, and rollnumber50, you declare one array variable such as rollnumb.


But in C, array always starts from 0 and end with size-1 and be written as

rollnumb[0], rollnumb[1]……….rollnumb[49]

and be declared as

int rollnumb[50];

means declaration syntax is

datatype  arrayname [size];

Types of array

  • One-Dimensional
  • Multi-Dimensional

One Dimensional Arrays

Array having only one subscript variable is called one-dimensional array and also called as single dimensional array or linear array.

Example of one dimensional array definition

int marks[5] = {50, 85, 60, 55, 90};

And represented as

marks[0] =50

marks[1] = 85

marks[2] = 60

marks[3] = 55

marks[4] = 90

A specific element in an array is accessed by an index.

Program 1 : Input and output of an Array

#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]);


Input of Array marks

(if you entered )






(you will get)

Output of Array marks

marks[0] =50

marks[1] = 85

marks[2] = 60

marks[3] = 55

marks[4] = 90

Multi Dimensional Arrays

Multidimensional 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]

Operations like

Traversing in arrays

Insertion in Arrays

Deletion in Arrays

Sorting and Searching in Array

Programming With C : Lecture 1

Programming With C : Lecture 2

Programming With C : Lecture 3

Programming With C : Lecture 4

Published by

Gagan Deep

FOUNDER & DIRECTOR, ROZY COMPUTECH SERVICES, KUK, KURUKSHETRA (HARYANA), INDIA I am in the profession of teaching in Computer Science since 1996.  In 1996, established a professional setup “Rozy Computech Services” for providing Computer Education, computer hardware and software services. In this span of 21 years , in conjunction with Rozy’s, I also associated in Teaching with different Institutions like Assistant Professor in University College, Kurukshetra University, Kurukshetra, Guest Faculty in Directorate of Distance Education, Kurukshetra University, Visiting Faculty in University Institute of Engineering & Technology, Kurukshetra University and a Resource person in EDUSAT, Haryana. Besides, I am also serving as Guide and Mentor in various private educational institutions. Also written 7 books on computer science.

3 thoughts on “Programming with C – Arrays- Lecture5

  1. hello sir i’m yours student inder josan from cheeka.
    i learn more about c language from here.
    i request you if you will discuss with us file handing( read file).,

  2. Hi Gagan,

    My name is Anuj Agarwal. I’m Founder of Feedspot.

    I would like to personally congratulate you as your blog Rozy Computech Services has been selected by our panelist as one of the Top 25 C Programming Blogs on the web.

    I personally give you a high-five and want to thank you for your contribution to this world. This is the most comprehensive list of Top 25 C Programming Blogs on the internet and I’m honored to have you as part of this!

    Also, you have the honor of displaying the badge on your blog.


Leave a Reply

Your email address will not be published. Required fields are marked *