Anda di halaman 1dari 15

DEPARTMENT OF TECHNICAL EDUCATION

ANDHRA PRADESH
Name of the faculty : K. Jeevan Kumar.
Designation : Lecturer.
Branch : Computer Engineering.
Institute : V.K.R & V.N.B Polytechnic.Gudivada.
Year/Semester : III Semester
Subject : UNIX & C
Subject Code : CM-304
Topic : Understand basics of Arrays.
Duration : 50 Min
Sub Topic : Array Declaration.
Teaching Aids : Diagram and animations,ppt.
CM304.57 1
Objective

On completion of this period you would be able


to know
 Array declaration
Two-dimensional.
Three-dimensional.

CM304.57 2
Recap

 Arrays: definition & declaration


 One dimensional arrays

CM304.57 3
Two-dimensional array

Definition : An array whose elements are


specified by two subscripts is called a
Two-dimensional array.

General form of Two-dimensional array


columns

datatype variable_name [size] [size];


rows
CM304.57 4
Simple program Two-dimensional array
#include<stdio.h>
datatyp
main( ) e
{ size
int a[2][2],i,j;
for(i =0;i<2;i++)
{
for (j=0;j<2;j++)
{
If (i==j)
a [i] [j]=1;
else
a [i] [j]=0;
}
}
CM304.57 5
Simple program Two-dimensional array
Contd..

for (i=0;i<2;i++)
{
for (j=0;j<2;j++)
printf (%d”, a [i] [j]); Output:
10
printf(“\n”); 01

}
}

CM304.57 6
Three-dimensional array
Definition : An array whose elements are specified
by three subscripts is called a Three-dimensional
array.

General form of Three-dimensional array:


columns
datatype variable_name [size][size][size];
rows
levels

CM304.57 7
Summary
 Declaration of two dimensional and three
dimensional arrays with general form and with
examples.

CM304.57 8
Quiz

1. What is two dimensional array?

a) elements have one subscript.

b) elements have two subscripts.

c) elements have three subscripts.

CM304.57 9
Quiz

1. What is two dimensional array?

a) elements have one subscript.

b) elements have two subscripts.

c) elements have three subscripts.

CM304.57 10
Quiz

2. What is three dimensional array?


a) elements have one subscript.
b) elements have two subscripts.
c) elements have three subscripts.

CM304.57 11
Quiz

2. What is three dimensional array?


a) elements have one subscript.
b) elements have two subscripts.
c) elements have three subscripts.

CM304.57 12
Quiz

3. In two dimensional what sizes are entered?


a) column sizes.
b) row sizes.
c) rows and columns.

CM304.57 13
Quiz

3. In two dimensional what sizes are entered?


a) column sizes.
b) row sizes.
c) rows and columns.

CM304.57 14
Frequently Asked Questions

1. Define two-dimensional array and represent


the same with the help of schematic diagram.
2. Define three-dimensional array and represent
the same with the help of schematic diagram.

CM304.57 15

Anda mungkin juga menyukai