-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path18_array_function_in_Pointers.cpp
More file actions
110 lines (76 loc) · 1.96 KB
/
18_array_function_in_Pointers.cpp
File metadata and controls
110 lines (76 loc) · 1.96 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
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
// Array
// #include <iostream>
// using namespace std;
// int main(){
// int arr[10] = {23 , 122 , 41 , 67};
// cout<< "Address of array " << arr << endl;
// cout<< "Address of array " << &arr[0] << endl;
// cout<< *arr << endl;
// cout<< *arr + 1 << endl;
// cout<< *(arr + 1) << endl;
// cout<< arr[2] << endl;
// cout<< *(arr + 2) << endl;
// // i[arr] = *(i + arr);
// // arr[i] = *(arr + i);
// }
// #include <iostream>
// using namespace std;
// int main(){
// int arr[10];
// // error !!!!
// // arr= arr + 1;
// int *ptr = &arr[0];
// cout<< ptr <<endl;
// ptr = ptr + 1;
// cout<< ptr <<endl;
// }
// character array
// #include <iostream>
// using namespace std;
// int main(){
// int arr[10] = {1,2,5,9};
// char ch[7] = "Rishav";
// cout<< arr << endl;
// cout<< ch << endl;
// char *ptr = &ch[0];
// cout<< ptr << endl;
// char temp = 'R';
// char *p = &temp;
// cout<< p <<endl;
// }
// pointers function
// #include <iostream>
// using namespace std;
// void print(int *p){
// cout<< p << endl;
// cout<< *p << endl;
// }
// void update(int *p){
// // p = p + 5;
// // cout<< "Inside : " << p <<endl;
// *p +=1;
// }
// int main(){
// int value = 5;
// int *p = &value;
// // print(p);
// cout<< "before address: " << p <<endl;
// cout<< "before Value: " << *p <<endl;
// update(p);
// cout<< "after address: " << p <<endl;
// cout<< "after value: " << *p <<endl;
// }
// #include <iostream>
// using namespace std;
// int getSum(int *arr,int n){
// cout<< sizeof(arr) << endl;
// int sum = 0;
// for(int i = 0; i < n; i++){
// sum+=arr[i];
// }
// return sum;
// }
// int main(){
// int arr[5] = {1 , 2 , 3 , 4, 5};
// cout<< "Sum is : " << getSum(arr + 2, 3);
// }