Lecture No.02 - Arrays
Lecture No.02 - Arrays
Algorithms
Mr. Tahir Iqbal
[email protected]
int a, b;
b = 2;
a = b;
a = 5;
2 = a;
Tahir Iqbal, Department of Computer Sciences, BULC
What is Array Name?
‘x’ is an array name but there is no variable x. ‘x’ is not an
lvalue.
For example, if we have the code
int a, b;
b = 2;
a = b;
a = 5;
2 = a;
Tahir Iqbal, Department of Computer Sciences, BULC
What is Array Name?
‘x’ is an array name but there is no variable x. ‘x’ is not an
lvalue.
For example, if we have the code
int a, b;
b = 2;
a = b;
a = 5;
2 = a;
Tahir Iqbal, Department of Computer Sciences, BULC
Array Name
‘x’ is not an lvalue
int x[6];
int n;
x[0] = 5;
x[1] = 2;
x = 3; // not allowed
x = a + b; // not allowed
x = &n; // not allowed
y = &x[0];
y = x; // x can appear on the right
// y gets the address of the
// first cell of the x array
y = &x[0];
y = x; // x can appear on the right
// y gets the address of the
// first cell of the x array
y = &x[0];
y = x; // x can appear on the right
// y gets the address of the
// first cell of the x array
delete[ ] y;
Real life:
a. shopping list,
b. groceries list,
c. list of people to invite to dinner
d. List of presents to get