-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtut13.cpp
More file actions
44 lines (38 loc) · 1.09 KB
/
tut13.cpp
File metadata and controls
44 lines (38 loc) · 1.09 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
#include<iostream>
using namespace std;
int main(){
int marks[] = {29, 13, 41, 27, 30};
cout<<marks[1]<<endl;
cout<<marks[2]<<endl;
int Mamarks[4];
Mamarks[0]=839;
Mamarks[1]=8900;
Mamarks[2]=2389;
cout<<"Marks are"<<endl;
cout<<Mamarks[0]<<endl;
cout<<Mamarks[1]<<endl;
cout<<Mamarks[2]<<endl;
// for ( int i = 0; i < 4; i++)
// {
// cout<<"The value of marks "<<i<<" is "<<marks[i]<<endl;
// }
//Doing the same using while-loop
// int i = 0;
// while ( i < 4)
// {
// cout<<"The value of marks "<<i<<" is "<<marks[i]<<endl;
// i++;
// }
//Pointers and arrays
int *p = marks;
cout<<"the value of marks[1] is "<< *p<<endl;
cout<<"the value of marks[2] is "<< *(p+1)<<endl;
cout<<"the value of marks[3] is "<< *(p+2)<<endl;
cout<<"the value of marks[4] is "<< *(p+3)<<endl;
cout<<"the value of marks[100] is "<< *(p+10)<<endl;
cout<<*(p++)<<endl;
cout<<*p<<endl;
cout<<*(++p)<<endl;
cout<<*p<<endl;
return 0;
}