Académique Documents
Professionnel Documents
Culture Documents
* element with 4th element using pointers. And display the results */
#include <stdio.h>
void main()
{
float x[10];
int i,n;
scanf("%d", &n);
for(i=0;i<n;i++)
{
scanf("%f",x+i);
}
printf("\nResultant Array...\n");
for(i=0;i<n;i++)
{
printf("X[%d] = %f\n",i,x[i]);
}
} /* End of main() */
/* Function to swap the 3rd element with the 4th element in the array */
temp = *ptr1;
*ptr1 = *ptr2;
*ptr2 = temp;
} /* End of Function */
/*-------------------------------------------
Output
How many Elements...
10
Enter Elements one by one
10
20
30
40
50
60
70
80
90
100
Resultant Array...
X[0] = 10.000000
X[1] = 20.000000
X[2] = 40.000000
X[3] = 30.000000
X[4] = 50.000000
X[5] = 60.000000
X[6] = 70.000000
X[7] = 80.000000
X[8] = 90.000000
X[9] = 100.000000
----------------------------------------------------*/