Pages

Monday, 21 May 2012

program to find operators by using pointer


114./*Write a program to find operators by using pointer*/

#include<stdio.h>
#include<conio.h>
void main()
{
            int x,a,y,b,*ptr1,*ptr2,c,d;
            clrscr();
            printf("\nENTER AN INTEGER:");
            scanf("%d",&x);
            fflush(stdin);
            printf("\nENTER AN INTERGER:");
            scanf("%d",&y);
            ptr1=&x;
            ptr2=&y;
            a=*ptr1-*ptr2;
            b=*ptr1* *ptr2+8;
            printf("\na=%d\nb=%d",a,b);
            printf("\nx-y or *ptr1-*ptr2=%d",a);
            printf("\nx*y+8 Or *ptr1* *ptr2+8=%d",b);
            printf("\nAddress of x=%u",ptr1);
            printf("\nAddress of y=%u",ptr2);
            c= 5-*ptr2 / *ptr1-2;
            printf("\nc=%d",c);
            *ptr1=*ptr2-5;
            printf("\nx=%d",*ptr1);
            d=*ptr1* *ptr2 *6;
            printf("\nc=%d",d);
            getch();
}

OUTPUT
            ENTER AN INTEGER : 6

ENTER AN INTEGER : 3

a =3
b = 26
x-y Or *ptr1 – “ptr2=3
x*y + 8 Or *ptr1 * *ptr2 + 8 = 26
Address of x = 65524
Address of y= 65520
C = 3
X = -2
C = -36

No comments:

Post a Comment