#include<iostream>

using namespace std;

int main(void)
{
	/*int b=30;
	float a=10.5;
	cout<<"\n\n\t::::::::::::::::::::::::::::::::::::::::::::::::::::::::::\n";
	cout<<"\t::  Memory Address   ::    Identifier    ::    Content  ::\n";
	cout<<"\t::::::::::::::::::::::::::::::::::::::::::::::::::::::::::\n";
	cout<<"\t::      "<<&a<<"     ::        a         ::     "<<a<<"    ::"<<endl;
	cout<<"\t::      "<<&b<<"     ::        b         ::      "<<b<<"     ::"<<endl;
	cout<<"\t::::::::::::::::::::::::::::::::::::::::::::::::::::::::::\n";*/
	
	/*int *intptr;
	int num=25;
	int x;
	
	cout<<" the address of x is "<< &x << endl;
	cout<<" the value of x is "<< x << endl;
	cout<<" the address of intptr is "<< &*intptr << endl;
	cout<<" the address of num is "<< &num << endl;
	cout<<" the value of num is "<< num << endl;
	
	x=num;
	intptr = &num;
	
	cout<<" the address of intptr is "<< &*intptr << endl;
	cout<<" the value of intptr is "<< *intptr << endl;
	cout<<" the address of x is "<< &x << endl;
	cout<<" the value of x is "<< x << endl;
	cout<<" the address of num is "<< &num << endl;
	cout<<" the value of num is "<< num << endl;
	
	int *ptr;
	int a = 5, b = 9;
	ptr = &a;

	
	cout<<" Value ptr "<<ptr<<endl;
	cout<<" Value b "<<b<<endl;
	//program 3
	int firstvalue, secondvalue = 20;
  int * p1, * p2;

  p1 = &firstvalue;  // p1 = address of firstvalue
  p2 = &secondvalue; // p2 = address of secondvalue
  *p1 = *p2 + 10;          // value pointed to by p1 = 10
  firstvalue=++*p1;
  secondvalue=*p2 + *p1;
  
  cout << "firstvalue is " << firstvalue << '\n';
  cout << "secondvalue is " << secondvalue << '\n'; 

//program 4
	int numbers[5];
  int * p;
  p = numbers;  *p = 1;
  p++;  *p = 2;
  p = &numbers[2];  *p = 3;
  p = numbers + 3;  *p = 4;
  p = numbers;  *(p+4) = 5;
  for (int n=0; n<5; n++)
    cout << numbers[n] << ", ";//1, 2, 3, 4, 5, 
   
   //program 5 
    int numbers[3]={10,11,12};
  int * p;
  p = numbers;  
  p=p+1;
  *p=*p+10;//20
  numbers[2]=++*p;
  p=numbers;
  *p=30;
  
  for (int n=0; n<3; n++)
    cout << numbers[n] << ", ";//20, 30, 12
    
	/*
//program 2
int firstvalue = 5, secondvalue = 15;
  int * p1, * p2;

cout << "firstvalue is " << firstvalue << '\n'; // firstvalue = 20
  cout << "secondvalue is " << secondvalue << '\n';
  cout<<'\n';
  
  p1 = &firstvalue;  // p1 = address of firstvalue
  
  cout << "firstvalue is " << firstvalue << '\n'; // firstvalue = 20
  cout << "secondvalue is " << secondvalue << '\n';
   cout<<'\n';
  p2 = &secondvalue; // p2 = address of secondvalue
  cout << "firstvalue is " << firstvalue << '\n'; // firstvalue = 20
  cout << "secondvalue is " << secondvalue << '\n';
   cout<<'\n';
  *p1 = 10;          // value pointed to by p1 = 10
  cout << "firstvalue is " << firstvalue << '\n'; // firstvalue = 20
  cout << "secondvalue is " << secondvalue << '\n';
   cout<<'\n';
  *p2 = *p1;         // value pointed to by p2 = value pointed to by p1
   cout<<'\n';
  cout << "firstvalue is " << firstvalue << '\n'; // firstvalue = 20
  cout << "secondvalue is " << secondvalue << '\n';
   cout<<'\n';
  p1 = p2;           // p1 = p2 (value of pointer is copied)
   cout<<'\n';
  cout << "firstvalue is " << firstvalue << '\n'; // firstvalue = 20
  cout << "secondvalue is " << secondvalue << '\n';
  *p1 = 20;          // value pointed to by p1 = 20
   cout<<'\n';
  cout << "firstvalue is " << firstvalue << '\n'; // firstvalue = 20
  cout << "secondvalue is " << secondvalue << '\n';// second value = 10*/

	short number[ ] = {10,20,30,40,50};
	short *p;
	
	p = number;
	p = p + 2;
	
	cout<<" value of p3 >> "<< *p;
}
