Question
Given below is a function called Reverse that reverses the input array. For example, if array elements are {1,2,3} it changes the values so that
Given below is a function called Reverse that reverses the input array. For example, if array elements are {1,2,3} it changes the values so that array becomes {3,2,1}.
The PrintArray function prints the input array.
The main() function first calls the PrintArray() function on the original array, then calls the Reverse() function to reverse the local array, finally calls PrintArray() again to display the arrays final contents.
Fill in the blanks to help the program work as it should.
void PrintArray (const int array[], int arraySize) // displays arrays elements { for (int i=0; i< .. ; i++) printf("%d ", ); printf(" "); }
void Reverse (int array[], int arraySize) { int temp, *start, *end;
start = .. ; end = &array[arraySize-1]; while ( end > start ) { temp = *start; *start = . ; *end = temp; start++; end--; } }
int main()
{
int my_numbers[] = {5, 6, 7, 33, 55, 34, 99, 100, 45, 4}; // has 10 elements printf ( "Initial array: " ); PrintArray ( my_numbers, 10 ); Reverse ( my_numbers, 10 ); printf ( "Reversed array: " ); PrintArray ( my_numbers, 10 );
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started