# include # include int main ( ) { int *ap; int i; int j; int n; // // Choose dimension at random between 1 and 100. // for ( i = 1; i <= 4; i++ ) { n = 1 + rand ( ) % 100; printf ( "\n" ); printf ( "Create int array of dimension N = %i\n", n ); // // Using malloc() and free() requires including stdlib.h. // ap = ( int * ) malloc ( n * sizeof ( int ) ); printf ( "Address of array is AP = %p\n", ap ); // // You can store information in the array using [] for indexing. // for ( j = 0; j < n; j++ ) { ap[j] = rand ( ) % 1000; } printf ( "Last entry in array is AP[%i] = %i\n", n-1, ap[n-1] ); printf ( "Last entry in array is *(AP+%i) = %i\n", n-1, *(ap+(n-1)) ); // // You can free up the memory using "free()"; // free ( ap ); } return 0; }