(i) initializing an array
Initializes an array of length 10 to 10,9,8,7,6,54,3,2,1
#include <stdio.h>voidInitint*PA,intN) { for(PA; pa<pa+n; pa++,n--) {*PA = n; }}intMain () {inta[Ten];inti =0;intm =sizeof(a)/sizeof(a[0]); Init (a,m); for(i=0; i<m; i++) {printf("%d", A[i]); }printf("\ n");return 0;}
(b) empty the array.
The contents of an array are completely cleared to 0.
#include <stdio.h>voidEmptyint*PA,intN) { for(PA; pa<pa+n; pa++,n--) {*pa =0; }}intMain () {inta[Ten] ={1,2,3,4,5,6,7,8,9,Ten};inti =0;intm =sizeof(a)/sizeof(a[0]); Empty (a,m); for(i=0; i<m; i++) {printf("%d", A[i]); }printf("\ n");return 0;}
(iii) array in reverse order
Arranges an array in reverse order and outputs.
#include <stdio.h>voidSort(int *pa,intN) {int *r= pa+n-1; for(; pa<r; pa++,r--) {intTMP =*pa;*pa=*r;*r= tmp; }}intMain () {inta[Ten] = {1,2,3,4,5,6,7,8,9,Ten};inti =0;int m= sizeof (a)/sizeof (a[0]);SortAm); for(i=0; i<m; i++) {printf("%d ", A[i]); }printf("\ n");return 0;}
(iv) displays an array.
Displays the contents of the array.
#include <stdio.h>void Show (int *pa,intN) {int *r= Pa+n; for(; pa<r; pa++) {printf("%d ",*pa); }}intMain () {inta[Ten] = {1,2,3,4,5,6,7,8,9,Ten};int m= sizeof (a)/sizeof (a[0]); Show (A,m);printf("\ n");return 0;}
The "C language" initializes, empties, reverse, and displays an array.