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.

Loader Loading...
EAD Logo Taking too long?

Reload Reload document
| Open Open in new tab


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.

19 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.


  3. I got what you intend, regards for posting. Woh I am glad to find this website through google.

  4. I think the admin of this page is actually working hard in support of his website, for the reason that here every material is quality based material.

  5. hello there and thank you for your info ? I have definitely picked up something new from right here. I did however expertise some technical issues using this web site, since I experienced to reload the website a lot of times previous to I could get it to load correctly. I had been wondering if your hosting is OK? Not that

  6. Hmm it looks like your site ate my first comment (it was super long) so I guess I’ll
    just sum it up what I wrote and say, I’m thoroughly enjoying your blog.
    I as well am an aspiring blog writer but I’m still new to everything.
    Do you have any tips and hints for rookie blog writers?
    I’d genuinely appreciate it.

  7. You’ve made some good points there. I looked on the internet for more info about the issue and found most individuals will go along with your views on this site.

  8. I’m impressed, I must say. Rarely do I come across a blog that’s
    both equally educative and amusing, and without a doubt, you have hit the
    nail on the head. The issue is something which too few men and women are speaking intelligently about.
    I am very happy that I came across this in my search for something regarding this.

  9. Having read this I believed it was really informative. I appreciate you spending some time
    and effort to put this short article together. I once again find myself spending way
    too much time both reading and commenting.

    But so what, it was still worthwhile!

  10. Hi there! I could have sworn I’ve been to this site before but after
    browsing through some of the post I realized it’s new to me.
    Anyhow, I’m definitely glad I found it and I’ll be bookmarking and checking back often!

  11. I really like your blog.. very nice colors & theme.
    Did you make this website yourself or did you hire someone to do it for you?
    Plz reply as I’m looking to design my own blog and would
    like to find out where u got this from. kudos

  12. Howdy! I could have sworn I’ve visited this web site before
    but after going through some of the posts I realized it’s new to me.
    Anyhow, I’m certainly happy I stumbled upon it and
    I’ll be book-marking it and checking back often!

  13. Article writing is also a fun, if you be familiar with afterward
    you can write or else it is complicated to write.

  14. I know this if off topic but I’m looking into starting my own blog and was
    wondering what all is needed to get setup? I’m assuming having a blog like
    yours would cost a pretty penny? I’m not very internet
    savvy so I’m not 100% positive. Any tips or advice would be greatly appreciated.
    Many thanks

  15. I have read so many posts regarding the blogger lovers
    however this post is genuinely a good piece of writing, keep it up.

  16. If some one needs expert view regarding blogging and
    site-building afterward i propose him/her to go to see this
    webpage, Keep up the pleasant job. 0mniartist asmr

Leave a Reply

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