"Construct a program that declares a size 10 array of doubles and an array of pointers to doubles.
In a for loop, using pointer arithmetic to increment, initialize the integer array from 1.0 to 10.0 and in same loop initialize the pointer array to point to the array elements holding the data.
Create a print function that accepts the pointer array and its size as an argument. The function should, using square bracket notation, print out the contents of the pointer array and the values in the double array.
An possible example of output:
0x001f20 1.0
0x001f28 2.0
etc."
this is what I have so far but its riddeled with errors
#include <stdio.h>
#define SIZE 10;
int main()
{
double values[10];
double *ptr[10];
int i;
for ( i = 0; i < SIZE; i++ ) {
(*(values + i) = i + 1;);
*(ptr + i) = values + i;
}
print(ptr, SIZE );
void print(double *ptr[SIZE], int size);
printf("%p %.1f\n", (void*)ptr[i], *ptr[i]);
}
I would really appreciate any help fixing this because its due monday.

New Topic/Question
Reply



MultiQuote



|