Professional Documents
Culture Documents
ARRAY
note
#include<stdio.h>
#include<conio.h>
void main()
{
int x=13,y=6,z;
z=x^y;
printf("value %d",z);
getch();
}
13 in binary =1011
6 in binary =0110
Xor for =1101
Multi-Dimensional Arrays
Multidimensional arrays are derived from the
basic or built-in data types of the C language.
Multi-dimensional Arrays
[2]
[0] [1] [2] [3] [1]
[0]
[0]
[0]
[1]
[1]
[2]
[2]
Two-Dimensional [3]
Declaration
Initialization
Storage allocation
Two - Dimensional Arrays
What is a Two-dimensional array?
Array type Array name
Array dimension = 2
51, 52, 53 Row 1
B= Int b[2][3] = {(51, 52, 53),(54, 55, 56)};
54, 55, 56 Row 2
Row 0 8 16 9 52
Row 1 3 15 27 6
Row 2 14 25 2 10
{4, 5, 6},
{7, 8, 9},
{10, 11, 12}};
int c[ ][3] = {{1, 2, 3},
{4, 5, 6},
{7, 8, 9},
{10, 11, 12}};
Implicitly declares the number of rows to be 4.
Input of Two-Dimensional Arrays
X1004
X1000
X1001
X1008
X1002
X100c X1003
x1010
Operators used in Pointers
Dereferencing Address
(
laV
)foeu
&
(Address of)
Int i=3;
‘&i’ variable
i
‘*i’
3
(Value of i)
Address of i
The value ‘3’ is saved in the memory location ‘x100c’
Syntax for pointers
(pointer type declaration)
type *identifier ;
Example
Char *cp ;
Int *ip ;
Double *dp ;
Pointer Assignment
b=a[0] ; pt
#include<conio.h>
void main()
int i=3;
int *j;
j=&i;
printf("i=%d \n",i);
printf("*j=%p\n",*j);
getch();
}
Int i=3; Create an integer variable ‘i’ and initialize it to 3
variabl
es Int *j Int i
M
e 3
m x100c
o
r
y
X1000 x1004 x1008 x100c x1010 x1014
Printf(“i=%d” i);
Printf(“*j=%p” *j);
Output
screen
i=3
*j=3
We know j=&i
So *j=*(&i) value of (address of
i)
(i.e.) value in address (x100c)
Int *j Int i
M
e 3
m x100c
o
r
y
X1000 x1004 x1008 x100c x1010 x1014
Predict the output of this code
#include<stdio.h>
#include<conio.h>
void main()
int num=10;
int* pnum=NULL;
pnum = #
*pnum += 20;