-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharray_basics.txt
More file actions
47 lines (34 loc) · 830 Bytes
/
Copy patharray_basics.txt
File metadata and controls
47 lines (34 loc) · 830 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
45
46
47
array
1.collection of items at continous memory location
2.same datatype are stored together
int arr[]={1,2,3,4,5,6,7}
3.array has index with it
4.access array
arr[0] is the index of element to be accessed
5.code
#include<iostream>
using namespace std;
int main()
{
int arr[5];
arr[0]=4;
arr[1]=2;
arr[2]=-10;
arr[3]=9;
arr[7]=21;
cout<<arr[3]<<endl;
// output of this much code -10
int arr1[5]={4,3,-10,9,21,12};
int arr2[]={5,3,12,6,9,43,33,56};
cout<<arr1[5]<<endl;
cout<<arr2[1]<<endl;
cout<<arr2[3/2]<<endl;
//output of above code is 12
//output of arr2 in above code is 3
//array always take floor value 3
int a[5] ={0};
cout<<a[4]<<endl;
//output 0
int a[5]={1};
cout<<a[4]<<endl;
//output 0 as this thing is valid for only 0 that assigning all element become 0