ARRAY Pointer C
ARRAY Pointer C
} int size;
float *ptr;
read (float *x, int *size) printf("enter the numbers\n");
{ ptr = read(&size); /*calling
int i=0; function*/
char c; for (i=0;i<size;i++)
printf ("enter the elements of printf("%f\n",*(ptr+i));
array\n"); }
do {
scanf("%f%c",(x+i),&c); float *read(int *size)
i++; * before function name required to
}while (c!='\n'); indicate to compiler that it will
*size=i; return a value of type float
} {
sort(float *x, int *size) int i=0;
{ char c;
int i,j; static float x[50];
for(i=0;i<*size-1;i++) do{
for (j=i+1;j<*size;j++) scanf("%f%c",&x[i],&c);
if(*(x+i)>*(x+j)) i++;
swap(i,j,x); }while (c!='\n');
} *size = i;
disp(float *x,int *size) return(x);
{ }
int i ; Static required else it variable will be
for(i=0;i<*size;i++) auto and auto variables will be
printf("%f\n",*(x+i)); erased when compiler comes to end
getchar(); of function, and attempt to acces
} such data will give garbage.
swap(int i,int j,float *x)
{
float p,q;
p = *(x+i);
q = *(x+j);
*(x+j) = p;
*(x+i) = q;
}