Arithmetic Operation in C using Pointer Variable


Write a program which perform arithmetic operation (+, -, *, / , %) which would be an example of demonstrating pointer arithmetic

Comments

  1. #include
    main()
    {
    int p,q,*x,*y,a,b,c,d;
    p=30,q=10;
    x=&p;
    y=&q;
    a=(*x)*(*y);
    b=a+(*x);
    c=5-((*x)/(*y));
    d=(*x)%(*y);
    printf("the values are:\n");
    printf("%d\n %d\n %d\n %d\n",a,b,c,d);
    }

    ReplyDelete
  2. #include
    #include
    int funcx();
    int main()
    {
    int shohan;
    int (*pFn)(void);
    pFn=funcx;
    printf("\n Arithmatic programme using pointer:");
    printf("\n Arithmatic value are:");
    shohan=(*pFn)();
    getch();
    return 0;
    }

    int funcx()
    {
    int a,b,*x,*y,p,q,r,s,t;
    a=20;
    b=10;
    x=&a;
    y=&b;
    p=(*x)*(*y);
    q=(*x)+(*y);
    r=p-(*x);
    s=q/(*y);
    t=r%(*x);
    printf("\n%d %d %d %d %d",p,q,r,s,t);
    }

    ReplyDelete
  3. #include
    #include
    main()
    {
    int p,q,*x,*y,a,b,c,d;
    p=40,q=15;
    x=&p;
    y=&q;
    a=(*x)*(*y);
    b=a+(*x);
    c=5-((*x)/(*y));
    d=(*x)%(*y);
    printf("the values are:\n");
    printf("%d\n %d\n %d\n %d\n",a,b,c,d);
    }

    ReplyDelete
  4. #include
    #include
    main()
    {
    int p,q,*x,*y,a,b,c,d;
    p=30,q=25;
    x=&p;
    y=&q;
    a=(*x)*(*y);
    b=a+(*x);
    c=5-((*x)/(*y));
    d=(*x)%(*y);
    printf("the values are:\n");
    printf("%d\n %d\n %d\n %d\n",a,b,c,d);
    }

    ReplyDelete
  5. #include
    main()
    {
    int a,b,out,*x,*y,out1,out2,out3,out4;
    printf("The value of A : ");
    scanf("%d",&a);
    printf("\nThe value of B : ");
    scanf("%d",&b);
    x=&a;y=&b;
    out=(*x + *y);
    out1=(*x - *y);
    out2=(*x * *y);
    out3=(*x / *y);
    out4=(*x % *y);
    printf("\naddition = %d \n",out);
    printf("\nsubtraction = %d\n",out1);
    printf("\nmultiplication = %d\n",out2);
    printf("\ndivision = %d\n",out3);
    printf("\nremainder after division = %d\n",out4);
    }

    ReplyDelete
  6. ID: 201820244
    Batch : 58 th
    section:B

    void main()
    {
    int p,q,*x,*y,m,n,o,s;
    p=30,q=25;
    x=&p;
    y=&q;
    m=(*x)*(*y);
    n=m+(*x);
    o=10-((*x)/(*y));
    s=(*x)%(*y);
    printf("the values are:\n");
    printf("%d\n %d\n %d\n %d\n",m,n,o,s);
    }

    ReplyDelete
  7. void main()
    {
    int p,q,*x,*y,m,n,o,s;
    p=30,q=25;
    x=&p;
    y=&q;
    m=(*x)*(*y);
    n=m+(*x);
    o=10-((*x)/(*y));
    s=(*x)%(*y);
    printf("the values are:\n");
    printf("%d\n %d\n %d\n %d\n",m,n,o,s);
    }

    ReplyDelete

Post a Comment