-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpointer-Arithmetic.c
More file actions
69 lines (57 loc) · 1.13 KB
/
pointer-Arithmetic.c
File metadata and controls
69 lines (57 loc) · 1.13 KB
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
// ================ increment
#include <stdio.h>
int main(){
int age = 10;
int *ptr = &age;
printf("%u\n" ,ptr);
*ptr++ ;
printf("%u\n" ,ptr);
return 0;
}
// ============= . decrement
#include <stdio.h>
int main(){
int age = 12;
int *ptr = &age;
*ptr++;
printf("%u\n", ptr);
*ptr--;
printf("%u\n", ptr);
return 0;
}
// ============ float increment ============
#include <stdio.h>
int main(){
float price = 20.00;
float *ptr = &price;
printf("Orginal Byets = %u\n" , ptr );
*ptr++;
printf("increment Byets = %u\n" , ptr );
*ptr--;
printf("decrement / orginal Byets = %u\n" , ptr );
return 0;
}
// ============ char increment ============
#include <stdio.h>
int main(){
char star = '*';
char *ptr = ☆
printf("Orginal Byets = %u\n" , ptr );
*ptr++ ;
printf("increment Byets = %u\n" , ptr);
*ptr--;
printf("dicrement / Orginal Byets %u\n" , ptr) ;
return 0;
}
// ======================
#include <stdio.h>
int main(){
int age = 22;
int _age = 50;
int *ptr = &age;
int *_ptr = &_age;
printf("Difference %d\n" ,ptr - _ptr );
_ptr = &age;
printf("Comparisome = %u\n", ptr == _ptr );
return 0;
}