Translate

Labels

Friday, 1 March 2013

POINTER OPERATORS & AND *

#include<stdio.h>
#include<conio.h>
void main()
{
int  x=10,*xp;
float  y=3.4,*yp;
char  z='a',*zp;
clrscr();
printf("x=%d\n",x);
printf("y=%f\n",y);
printf("z=%c\n,z");
xp=&x;
printf("\n Address of x=%u\n",xp);
printf("Value of x=%d\n",*xp);
yp=&y;
printf("\n Address of y=%u\n",yp);
printf("Value of y=%f\n",*yp);
zp=&z;
printf("\n Address of z=%u\n",zp);
printf("Value of x=%c\n",*zp);
getch();
}


  • In the above program concept of pointer operators illustrated,x,y and z  are declared to be variables of int, float and char type, respectively.  xp ,yp and zp are declared to be pointer variables of type int, float and char type, respectively.
  • The initial values of x, y, and z are displayed. The pointer variable xp is assigned the address of x using the statement xp=&x;the address of x and its value are displayed through the pointer variable.The same thing is repeated for char and float.

No comments: