Page 1 of 1

Pointer Arithmetic Operations #include using namespace std; int main() = int * p; int a [10]; int index; for

Posted: Sun May 15, 2022 11:50 am
by answerhappygod
Pointer Arithmetic Operations Include Iostream Using Namespace Std Int Main Int P Int A 10 Int Index For 1
Pointer Arithmetic Operations Include Iostream Using Namespace Std Int Main Int P Int A 10 Int Index For 1 (39.68 KiB) Viewed 32 times
Pointer Arithmetic Operations #include <iostream> using namespace std; int main() = int * p; int a [10]; int index; for (index = 0; index <10; index++) a[index] index; p = a; // After this assignment, p points to the same memory location that a points to. So, p[0l, pil), p19) refer to the indexed variables a[0]... a[9]. //int *p2; a = p2; // is illegal for (index = 0; index < 10; index++) cout << p[index] < " "; cout << endl; for (index = 0; index <10; index++) *(p+index) =* (p+index) +1; // same as: p[index] = p[index] + 1; for (index = 0; index < 10; index++) cout << a[index] «""; // same as: cout << * (p+index) < " "; and cout << p[index] << " "; cout << endl; return 0; 1