#include<stdio.h> main() { int a=5,*p,*q; p=&a; q=p; printf("\n%d %d %d",a,*p,*q); a++; (*p)++; (*q)++; printf("\n%d %d %d",a,*p,*q); }
5 5 5 8 8 8
#include<stdio.h> main() { int a=5,b=10,*p,*q; p=&a; q=&b; printf("\n%d %d %d %d",a,b,*p,*q); (*p)++; (*q)--; printf("\n%d %d %d %d",a,b,*p,*q); *p=*p+5; *q=*q-5; printf("\n%d %d %d %d",a,b,*p,*q); }
5 10 5 10 6 9 6 9 11 4 11 4
#include<stdio.h> main() { int a=5,b=10,*p,*q; p=&a; q=&b; printf("\n%d %d %d %d",a,b,*p,*q); a=b; (*p)++; (*q)--; printf("\n%d %d %d %d",a,b,*p,*q); *p=*q; (*p)++; (*q)--; printf("\n%d %d %d %d",a,b,*p,*q); }
5 10 5 10 11 9 11 9 10 8 10 8
#include<stdio.h> main() { int a=5,b=10,*p,*q; p=&a; q=&b; printf("\n%d %d %d %d",a,b,*p,*q); *p=*q; *p=*p+*q; *q=*p-*q; printf("\n%d %d %d %d",a,b,*p,*q); p=q; (*p)++; (*q)--; printf("\n%d %d %d %d",a,b,*p,*q); }
5 10 5 10 20 10 20 10 20 10 10 10
#include<stdio.h> main() { float a [5]={1.2,4.8,3.6,7.1,0.2}; float *p; p=a; printf("Result is %f\n",a[2]); printf("Result is %f\n",2[a]); printf("Result is %f\n",*(p+2)); printf("Result is %f\n",*(a+2)); }
Result is 3.600000 Result is 3.600000 Result is 3.600000 Result is 3.600000