1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
#include <stdio.h>
void change( float * const array, float *nPtr);
float sum( float * const array, int *size);
int main()
{
int size = 10;
float array[] = { 1, 2, 3, 5, 7, 11, 13, 17, 19, 23 };
int j=0;
float total;
printf("\nThe size of the array is: %d\n", size);
printf("%s\n", "List");
for ( j = 0; j < size; j++) {
printf( "%.2f\n", array[j] );
}
change ( array, &array[3]);
printf("%s\n", "The new array is: ");
for ( j = 0; j < size; j++) {
printf( "%.2f\n", array[j] );
}
total = sum( array, &size);
printf("The total is %.2f\n", total);
return 0;
}
void change( float * const array[], float *nPtr)
{
*nPtr = *(array[3] + 5);
}
float sum( float * const array[], int *size)
{
float total = 0;
int j = 0;
for ( j = 0; j < *size; j++){
total = total + array[j];
}
return total;
};
|