Upcoming SlideShare
×

# Array in C

5,441 views
5,192 views

Published on

This slide contain the introduction to the arrays available in C programming language.

Published in: Education, Technology
10 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
Your message goes here
• Be the first to comment

Views
Total views
5,441
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
497
0
Likes
10
Embeds 0
No embeds

No notes for slide

### Array in C

1. 1. INTRODUCTION ONE-DIMENSIONAL ARRAY MULTIDIMENSIONAL ARRAY Array
2. 2. Introduction  It holds multiple values of same type.  Each block of array is stored consecutively in memory. SYNTAX: data-type name[size1][size2]………[sizen]; Example: int a[6];
3. 3. Advantage of Array  Huge amount of data can be stored under single variable name.  Searching of data item is faster.  2 dimension arrays are used to represent the matrices.  It is helpful in implementing other data structure like linked list, queue,stack.
4. 4. One dimensional Array SYNTAX: data-type name[index]; EXAMPLE: int num[10];
5. 5. Initialization  int num[6]={2,4,6,7,8,12};  Individual elements can also be initialize as:  num[0]=2;  num[1]=4;  num[2]=6;  num[3]=7;  num[4]=8;  num[5]=12;
6. 6. Reading Data from User  for loop is used to read data from the user.
7. 7. Class work  WAP to read 10 numbers from the user and display them.  WAP to read 20 numbers from the user and find out the highest number.
8. 8. Multi-dimensional Array  In multi-dimensional we focus on the two dimensional array. SYNTAX: data-type name[row-size][column-size]; EXAMPLE: int a[3][4];
9. 9. Initialization  int odd[3][2]={1,3,5,7,9,11};  Individual element can also be assigned as:  Odd[0][0]=1;  Odd[0][1]=3;  Odd[1][0]=5;  Odd[1][1]=7;  Odd[2][0]=9;  Odd[2][1]=11;
10. 10. Reading Data from the user  Nested for Loop is used.
11. 11. Class Work  WAP to read a 3*3 matrix from the user and display it in the appropriate format.  WAP to read two 3*3 matrices from the user and display their sum.