9953330565 Low Rate Call Girls In Rohini Delhi NCR
arrays.pptx
1. Arrays
• Array is a seq of objects of same data type
• The objects in an array is also called elements
of array
• It is a consecutive group of storage units
• These locations are referred by a single
variable called array name.
• Each element then is referred by its position in
the array
2. Array
• 0 represents the first index
• N-1 represents the last
• Two types
– One-dimensional
– Multi-dimensional array
5. Declaring of one-dimensional array
• When an array is declared , a memory block
with the required number of locations is
reserved in the computer memory for storing
the data into elements of the array.
• General syntax
– Type name [n];
• N is an unsigned integer value . It represents the total
number of elements of the array.
7. float a[5];
int i;
a[0]=9.9;
a[1]= 12.9;
a[2]= 13.1;
a[3]=9.8;
a[4]=10.6;
For (i=0;i<=4;i++)
{
cout<<“value in a[“<<i<<“] =“<< a[i]<<endl;
}
8. • Write a program to take integer type data in
an array and print it in reverse order.
• Take 5 elements calculate sum and avg than
print the sum and avg
• Find the max value in an array;
• Write a program to input data into two
different array and then store the sum of them
in third array
10. Multidimensional Array
• A multi-dimensional array is an array of more
than one array
• i.e. an array of two one-dimensional arrays is
called two-dimensional array, it is also known
as table or matrix.
• Rows into columns
• Temp[6][2]
11. • Type name [r][c]
– Int abc[12][3]
– Total number of elements = 12*3=36
– Float a,b,c[10],x[8][4],y,ab[12][3]
12. • Storing and retrieval of data in multidimensional array
r=0
While(r<=the size of row)
{
C=0;
while(c<=size of column)
{
C++;
}
R++
}