Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. Write a function that prints a one dimensional array of doubles to the screen

ID: 3626471 • Letter: 1

Question

1. Write a function that prints a one dimensional array of doubles to the screen. The prototype is:
void printArrayForward(double* array, int size);
and write a function that prints a one dimensional array of doubles to the screen in reverse order, ie last element first, etc. The prototype is:
void printArrayForwardReverse(double* array, int size);
Your functions must use pointer arithmetic to access elements of the array. Write a driver program to test your functions. (For simplicity, use {..} notation to declare and fill a short array of doubles.) DO NOT use index notation, ie array[i], or in your driver program.

I will appreciate the response in C Programming. Thank you!

Explanation / Answer

#include<stdio.h>
void printArrayForward(double* array, int size)
{
int i;
for(i=0; i<size; i++)
printf("%lf ",*(array+i));
printf(" ");
}
void printArrayForwardReverse(double* array, int size)
{
int i;
for(i=size-1; i>=0; i--)
printf("%lf ",*(array+i));
printf(" ");
}
int main()
{
double a[]={1.2,3.4,5.6,7.8,9.0,0.9};
printArrayForward(a,6);
printArrayForwardReverse(a,6);
return 0;
}