-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpointer.cpp
More file actions
94 lines (85 loc) · 2.18 KB
/
Copy pathpointer.cpp
File metadata and controls
94 lines (85 loc) · 2.18 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#include<iostream>
using namespace std;
int main(){
// int a = 3;
// int* b = &a;
// & -> (Address of) operator
// cout<<"The address of a is: "<<b<<endl;
// cout<<"The address of a is: "<<&a<<endl;
// * -> (value at) Dereference operator
// cout<<"The value at address of b is: "<<*b<<endl;
// array
int marks[] = {79, 89, 76, 88};
// cout<<*marks<<endl;
// cout<<*(marks+1)<<endl;
// cout<<*(marks+2)<<endl;
// cout<<*(marks+3)<<endl;
// array pointer
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;
cout<<"the value of *(p+3) is: "<<*(p+3)<<endl;
// int mm[4];
// mm[0] = 89;
// mm[1] = 90;
// mm[2] = 91;
// mm[3] = 92;
// cout<<mm[0]<<endl;
// cout<<mm[1]<<endl;
// cout<<mm[2]<<endl;
// cout<<mm[3]<<endl;
// for (int i = 0; i < 4; i++){
// cout<<"The value of marks "<<i<<" is "<<mm[i]<<endl;
// }
// value of mm is change 92 to 95
// mm[3] = 95;
// int i = 0;
// using while loop to iterate mm array elements
// while(i<4){
// cout<<"The value of marks "<<i<<" is "<<mm[i]<<endl;
// i++;
// }
// ud=sing do while loop to iterate mm array elements
// do
// {
// cout<<"The value of marks "<<i<<" is "<<mm[i]<<endl;
// i++;
// } while (i < 4);
// using while loop to print a pattern
// * * * * *
// * * *
// * *
// *
// int n = 5;
// int j = 1;
// while(j <= n){
// int k = 1;
// while(k<j){
// cout<<" ";
// k++;
// }
// int m = 1;
// while(m<=n-j+1){
// cout<<"* ";
// m++;
// }
// cout<<endl;
// j++;
// }
// using for loop to print a pattern
// * * * * *
// * * *
// * *
// *
// for(int j = 1; j<=n; j++){
// for(int k = 1; k<j; k++){
// cout<<" ";
// }
// for(int m = 1; m<=n-j+1; m++){
// cout<<"* ";
// }
// cout<<endl;
// }
return 0;
}