-->

program to understand array as pointer

using codeblocks
-------------------------------------------------------------------------------------------------------
//understanding array as pointer      //comment of program
#include <stdio.h>                     //header file
int main()
{
    int a[]={2,3,4,5,6};                 //array with some values
    int i;
    printf("the values are\n");
    for(i=0;i<=4;i++)
    {
        printf("location =%d and value=%d\n",i,a[i]);//prints value without pointer
    }
    printf("printing value using array as pointer\n");
    for(i=0;i<=4;i++)
    {
        printf("location =%d and value=%d\n",i,*(a+i));
        //prints value with pointer. 'a' is an array; 'i' is for location.
        //To display value, we use '*' with location; as shown here.
    }
    printf("printing address using array as pointer\n");
    for(i=0;i<=4;i++)
    {
        printf("location =%d and value=%d\n",i,(a+i));//prints address of different location
    }
    return 0;
}
----------------------------------------------------------------------------------------
using turbo c++
---------------------------------------------------------------------------------------------------
//understanding array as pointer      //comment of program
#include <stdio.h>                     //header file
#include<conio.h>
int main()
{
    int a[]={2,3,4,5,6};                 //array with some values
    int i;
    printf("the values are\n");
    for(i=0;i<=4;i++)
    {
        printf("location =%d and value=%d\n",i,a[i]);//prints value without pointer
    }
    printf("printing value using array as pointer\n");
    for(i=0;i<=4;i++)
    {
        printf("location =%d and value=%d\n",i,*(a+i));
        //prints value with pointer. 'a' is an array; 'i' is for location.
        //To display value, we use '*' with location; as shown here.
    }
    printf("printing address using array as pointer\n");
    for(i=0;i<=4;i++)
    {
        printf("location =%d and value=%d\n",i,(a+i));//prints address of different location
    }
   getch();
    return 0;
}

program to compare of two numbers using pointer

//comparison of two numbers using pointer     //comment of program
#include <stdio.h>                           //header file
int main()
{
    float *p,*p1;                        //two pointer declaration
    float x,y;                           //variable declaration
    printf("enter two values for x and y\n");//prints message
    scanf("%f%f",&x,&y);                    // gets input
    p=&x,p1=&y;                        //assigning address to that pointer
    printf("the address of x(%f) is=%f\n",x,p);//display of that address
    printf("the address of y(%f) is=%f\n",y,p1);//display of address of second variable
    if(*p>*p1)                              //comparison of two values using pointer
    {
       printf("%f is greater \n",*p);
    }
    else
    {
        printf("%f is greater \n",*p1);
    }

        return 0;
}
----------------------------------------------------------------------------------------------------

using turboc++
---------------------------------------------------------------------------------------------------
//comparison of two numbers using pointer     //comment of program
#include <stdio.h>                           //header file
#include<conio.h>
int main()
{
    float *p,*p1;                        //two pointer declaration
    float x,y;                           //variable declaration
    printf("enter two values for x and y\n");//prints message
    scanf("%f%f",&x,&y);                    // gets input
    p=&x,p1=&y;                        //assigning address to that pointer
    printf("the address of x(%f) is=%f\n",x,p);//display of that address
    printf("the address of y(%f) is=%f\n",y,p1);//display of address of second variable
    if(*p>*p1)                              //comparison of two values using pointer
    {
       printf("%f is greater \n",*p);
    }
    else
    {
        printf("%f is greater \n",*p1);
    }
       getch();
        return 0;
}

program for division and multiplication of two numbers using pointer

using codeblocks
------------------------------------------------------------------------
//division and multiplication of two numbers using pointer     //comment of program
#include <stdio.h>                     //header file
int main()
{
    float *p,*p1;                        //two pointer declaration
    float x,y;                           //variable declaration
    printf("enter two values for x and y\n");//prints message
    scanf("%f%f",&x,&y);                    // gets input
    p=&x,p1=&y;                        //assigning address to that pointer
    printf("the address of x(%f) is=%f\n",x,p);//display of that address
    printf("the address of y(%f) is=%f\n",y,p1);//display of address of second variable
    printf("the product=%f\n",(*p)*(*p1)); 
 //display of multiplication stored in that address. we display that using indirection operator

    printf("the quotient=%f",(*p)/(*p1));//display of quotient part
    return 0;
}
-------------------------------------------------------------------------------------------------------
using turboc++
-----------------------------------------------------------------------------------------------------
//division and multiplication of two numbers using pointer     //comment of program
#include <stdio.h>                     //header file
#include<conio.h>
int main()
{
    float *p,*p1;                        //two pointer declaration
    float x,y;                           //variable declaration
    printf("enter two values for x and y\n");//prints message
    scanf("%f%f",&x,&y);                    // gets input
    p=&x,p1=&y;                        //assigning address to that pointer
    printf("the address of x(%f) is=%f\n",x,p);//display of that address
    printf("the address of y(%f) is=%f\n",y,p1);//display of address of second variable
    printf("the product=%f\n",(*p)*(*p1));    
//display of multiplication stored in that address. we display that using indirection operator

    printf("the quotient=%f",(*p)/(*p1));//display of quotient part
   getch();
    return 0;
}

program to get difference of two numbers using pointer

using codeblocks
-------------------------------------------------------------------------------------------------------------

//difference of two numbers using pointer     //comment of program
#include <stdio.h>                     //header file
int main()
{
    int *p,*p1;                      //two pointer declaration
    int x,y;                           //variable declaration
    printf("enter two values for x and y\n");//prints message
    scanf("%d%d",&x,&y);                    // gets input
    p=&x,p1=&y;                        //assigning address to that pointer
    printf("the address of x(%d) is=%d\n",x,p);//display of that address
    printf("the address of y(%d) is=%d\n",y,p1);//display of address of second variable
    printf("the difference=%d\n",*p-*p1);   
//display of difference stored in that address. we display that using indirection operator
    return 0;
}

-----------------------------------------------------------------------------------
using turbo c++
-----------------------------------------------------------------------------------------------------
//difference of two numbers using pointer     //comment of program
#include <stdio.h>                     //header file
#include<conio.h>                    //header file
int main()
{
    int *p,*p1;                      //two pointer declaration
    int x,y;                           //variable declaration
    printf("enter two values for x and y\n");//prints message
    scanf("%d%d",&x,&y);                    // gets input
    p=&x,p1=&y;                        //assigning address to that pointer
    printf("the address of x(%d) is=%d\n",x,p);//display of that address
    printf("the address of y(%d) is=%d\n",y,p1);//display of address of second variable
    printf("the difference=%d\n",*p-*p1);   
//display of difference stored in that address. we display that using indirection operator
   getch();                              //holds the output
    return 0;
}

program to get sum of two numbers using pointer

using codeblocks
----------------------------------------------------------------------
//sum of two numbers using pointer     //comment of program
#include <stdio.h>                     //header file
int main()
{
    int *p,*p1;                      //two pointer declaration
    int x,y;                           //variable declaration
    printf("enter two values for x and y\n");//prints message
    scanf("%d%d",&x,&y);                    // gets input
    p=&x,p1=&y;                        //assigning address to that pointer
    printf("the address of x(%d) is=%d\n",x,p);//display of that address
    printf("the address of y(%d) is=%d\n",y,p1);//display of address of second variable
    printf("the sum=%d\n",*p+*p1); 
 //display of sum stored in that address. we display that using indirection operator
    return 0;
}
-----------------------------------------------------------------------------------------------
using turboc++
------------------------------------------------------------------------------------------
//sum of two numbers using pointer     //comment of program
#include <stdio.h>                     //header file
#include<conio.h>
int main()
{
    int *p,*p1;                      //two pointer declaration
    int x,y;                           //variable declaration
    printf("enter two values for x and y\n");//prints message
    scanf("%d%d",&x,&y);                    // gets input
    p=&x,p1=&y;                        //assigning address to that pointer
    printf("the address of x(%d) is=%d\n",x,p);//display of that address
    printf("the address of y(%d) is=%d\n",y,p1);//display of address of second variable
    printf("the sum=%d\n",*p+*p1);    
//display of sum stored in that address. we display that using indirection operator
    getch();
    return 0;
}


Program to show pointer for increment and decrement operator.

using codeblocks
---------------------------------------------------------------------------

//understanding pointer  increment and decrement              //comment of program
#include <stdio.h>                     //header file
int main()
{
    int *pointer;                      //pointer declaration
    int x=4;                           //value assignment
    pointer=&x;                        //assigning address to that pointer
    printf("the address of x is=%d\n",pointer);//display of that address
    printf("the  value of x=%d\n",*pointer);    //display of value stored in that address. we display that using indirection operator
   pointer++;                             //increment of address by 1
   printf("pointer ++=%d\n",pointer);       //display of that address
   pointer--;                            //pointer decrement
   printf("pointer --=%d",pointer);       //display of that address

    return 0;
}


-------------------------------------------------------------------------------------------------------------
using turboc++
----------------------------------------------------------------------------------------------------------
//understanding pointer  increment and decrement              //comment of program
#include <stdio.h>                     //header file
#include<conio.h>
int main()
{
    int *pointer;                      //pointer declaration
    int x=4;                           //value assignment
    pointer=&x;                        //assigning address to that pointer
    printf("the address of x is=%d\n",pointer);//display of that address
    printf("the  value of x=%d\n",*pointer);    //display of value stored in that address. we display that using indirection operator
   pointer++;                             //increment of address by 1
   printf("pointer ++=%d\n",pointer);       //display of that address
   pointer--;                            //pointer decrement
   printf("pointer --=%d",pointer);       //display of that address
  getch();                                           //to hold the output
    return 0;
}