Skip to content

Commit ff5ece1

Browse files
Add files via upload
1 parent d2fdac9 commit ff5ece1

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

23_pointerwithArrays.cpp

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include <iostream>
2+
using namespace std;
3+
4+
int main(){
5+
int arr[10] = {2,4,6,5,8,9,1,3,5,7};//When we write this, arr is basically the address of the memory block at first position or of 0th index.
6+
int* ptr = &arr[0];//in the same way we can create a pointer which points to the first block of array
7+
8+
// Printing the address of the first memory block in various ways
9+
cout<<"Address of the a[0] is: "<<arr<<endl;
10+
cout<<"Address of first block is: "<< &arr[0]<<endl;
11+
cout<<"Address stored by the pointer is: "<<ptr<<endl;
12+
13+
14+
// Printing the value of the a[0] in various ways
15+
cout<<endl;
16+
cout<<"Value at a[0] is: "<<arr[0]<<endl;
17+
cout<<"Value at the address stored by the pointer is: "<<*ptr<<endl;
18+
19+
20+
21+
return 0;
22+
}

23_pointerwithArrays.exe

44.1 KB
Binary file not shown.

0 commit comments

Comments
 (0)