/*WAP TO DEMONSTRATE USE OF ADDRESS OF OPERATOR(&)
AND INDIRECTION OPERATOR(*) FOR DIFF. PURPOSES*/
#include<conio.h>
#include<stdio.h>
void main()
{
int i=5,j=2,*ptr;
ptr=&i;
clrscr();
printf("\n\nADDRESS OF i=%u",&i);
printf("\n\nVALUE STORED IN ptr=%u",ptr);
printf("\n\nVALUE POINTED BY ptr=%d",*ptr);
*ptr=10;
printf("\n\nVALUE OF i=%d",i);
j=*ptr;
printf("\n\nVALUE OF j=%d",j);
getch();
}
/**************************************************************************
OUTPUT
**************************************************************************
ADDRESS OF i=65524
VALUE STORED IN ptr=65524
VALUE POINTED BY ptr=5
VALUE OF i=10
VALUE OF j=10
*/
No comments:
Post a Comment