-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSession4.cpp
More file actions
44 lines (31 loc) · 779 Bytes
/
Session4.cpp
File metadata and controls
44 lines (31 loc) · 779 Bytes
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
#include<iostream>
using namespace std;
int main(){
// a is created in stack
int a = 10; // ok
// int a = 10, 20; error, as a is a single value container
// Multi Value Container : Array
// arr is also in stack
// arr will not show value, it will show address of 1st element in array !!
// Array is Homogeneous Storage Container i.e. Data must be same type
int arr[10];
cout<<"a is: "<<a<<"\n";
cout<<"arr is: "<<arr<<"\n";
cout<<"Address of a is: "<<&a<<"\n";
cout<<"Address of arr is: "<<&arr<<"\n";
/*
arr[0] = 10;
arr[1] = 20;
arr[9] = 111;
*/
// Write Operation in Array
for(int i=0;i<10;i++){
// arr[i] = 10*(i+1);
cin>>arr[i];
}
// Read Operation in Array
for(int i=0;i<10;i++){
cout<<arr[i]<<" "<<&arr[i]<<"\n";
}
return 0;
}