-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtut50.cpp
More file actions
34 lines (30 loc) · 804 Bytes
/
tut50.cpp
File metadata and controls
34 lines (30 loc) · 804 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
#include <iostream>
using namespace std;
int main()
{
// Basic example of pointers.
// int a = 4 ;
// int * ptr = &a;
// cout<<"The value of a is "<<*(ptr)<<endl;
// // New keyword progpram
// // int *p = new int(5);
// float *p = new float(5.45);
// cout<<"The value at address p is: "<<*(p)<<endl;
// Making array dynamically
int *arr = new int[4];
arr[0] = 45 ;
*(arr+1) = 54 ;
arr[2] = 43 ;
arr[3] = 34 ;
// for (int i = 0; i < 4; i++)
// {
// cout<<"Enter the elements of the array: "<<endl;
// cin >> arr[i];
// }
// delete[] arr ; // used to free the array using delete function.
for (int i = 0; i < 4; i++)
{
cout << "The elements of array are: " << arr[i] << "\n";
}
return 0;
}