-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtut13.cpp
More file actions
70 lines (53 loc) · 1.44 KB
/
Copy pathtut13.cpp
File metadata and controls
70 lines (53 loc) · 1.44 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
#include<iostream>
using namespace std;
int main(){
int marks[] = {23, 69, 45, 99};
cout<<"These are marks"<<endl;
cout<<marks[0]<<endl;
cout<<marks[1]<<endl;
cout<<marks[2]<<endl;
cout<<marks[3]<<endl;
int mathmarks[4];
mathmarks[0] = 45;
mathmarks[1] = 56;
mathmarks[2] = 69;
mathmarks[3] = 78;
//You can change marks of a array after aassigned.
mathmarks[2] = 100;
cout<<"The are math marks"<<endl;
cout<<mathmarks[0]<<endl;
cout<<mathmarks[1]<<endl;
cout<<mathmarks[2]<<endl;
cout<<mathmarks[3]<<endl;
cout<<endl;
cout<<endl;
for(int i = 0; i < 4; i++){
cout<<"The value of math marks "<<i<<" is "<<mathmarks[i]<<endl;
}
cout<<endl;
cout<<endl;
int i = 0;
while (i<4)
{
cout<<"The value of math marks "<<i<<" is "<<mathmarks[i]<<endl;
i++;
}
cout<<endl;
cout<<endl;
int a = 0;
do
{
cout<<"The value of math marks "<<a<<" is "<<mathmarks[a]<<endl;
a++;
} while (a<4);
cout<<endl;
cout<<endl;
//Pointers in Array
//Pointer arithmetic ---> address(new) = address(old) + (i * size of datatype)
int *p = marks;
cout<<"The value of *p is "<<*p<<endl;
cout<<"The value of *(p+1) is "<<*(p+1)<<endl;
cout<<"The value of *(p+2) is "<<*(p+2)<<endl; // () ----> is very important
cout<<"The value of *(p+3) is "<<*(p+3)<<endl;
return 0;
}