-
Notifications
You must be signed in to change notification settings - Fork 0
/
Addition to address
114 lines (72 loc) · 1.74 KB
/
Addition to address
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
//PROGRAM FOR ADDING ONE TO ADDRESS BY USING CHARACTER.
#include <stdio.h>
int main(void)
{
char c='z';//to initialise character and assign z to character c
char*cp=&c;//address of c is assigned to the pointer cp
printf("cp is %p\n",cp);//to print the address
printf("The character at cp is %c\n",*cp);//to print the value of c
cp=cp+1;//adding 1 to the address
printf("cp is %p\n",cp);//to print the new address
return 0;
}
//PROGRAM FOR ADDING ONE TO ADDRESS BY USING INTEGER.
#include <stdio.h>
int main(void)
{
int x=2;
int*px=&x;
printf("The address of x is %p\n",px);
printf("The value at cp is %d\n",*px);
px=px+1;
printf("Address of px+1 is %p\n",px);
return 0;
}
//PROGRAM FOR ADDING ONE TO ADDRESS BY USING DOUBLE.
#include <stdio.h>
int main(void)
{
double x=2;
double*px=&x;
printf("The address of x is %p\n",px);
printf("The value at cp is %lf\n",*px);
px=px+1;
printf("Address of px+1 is %p\n",px);
return 0;
}
//PROGRAM FOR ADDING TWO TO ADDRESS BY USING DOUBLE.
#include <stdio.h>
int main(void)
{
double x=2;
double*px=&x;
printf("The address of x is %p\n",px);
printf("The value at cp is %lf\n",*px);
px=px+2;
printf("Address of px+2 is %p\n",px);
return 0;
}
//PROGRAM FOR ADDING TWO TO ADDRESS BY USING INTEGER.
#include <stdio.h>
int main(void)
{
int x=2;
int*px=&x;
printf("The address of x is %p\n",px);
printf("The value at cp is %d\n",*px);
px=px+2;
printf("Address of px+2 is %p\n",px);
return 0;
}
//PROGRAM FOR ADDING ONE TO ADDRESS BY USING CHARACTER.
#include <stdio.h>
int main(void)
{
char c='z';
char*cp=&c;
printf("cp is %p\n",cp);
printf("The character at cp is %c\n",*cp);
cp=cp+2;
printf("cp is %p\n",cp);
return 0;
}