use c code to develop the condition and function for the following items and then redevelop the code by adding the function as shown below, the original code has been given below. Hint: a)the function need to be made and develop  and than add to the code 1. print Reverse 2. void reverseIt 3. void search Array 4.void search array 5. void array copy and void arrayDiff) b) the answer must be include and output and c code void printReverse(int array[], size); //prints the array reversely void reverseIt(int array[], size); //reverses an array void searchArray(int array[], int size, int num); // returns the first index of the array whose value is num. //returns -1 if the number was not found in the array // optional for lab 6: void searchnArray(int array[], int size, int num, int n); // returns the nth index of the array whose value is num. //returns -1 if the number was not found in the array void arrayCopy (int arDest[], int arSource[], int commonSize); // copies cells from arSourc to arDest void arrayDiff (int ar1[], int ar2[], int commonSize); // returns the number of differences between array elements (how many cells are different) int main(void) { int ar[6]={1, 0, 2, -1, 4, 3}; int arSize = 6; int lp , rp, i; printf("before sort: "); printArray(ar, arSize); //ascending sort - increasing sortArrayDESC(ar, arSize); printf("\nafter sort: "); printArray(ar, arSize); } void sortArrayASC(int array[], int size) { int lp , rp; for (lp = 0 ; lp < size -1 ; lp = lp + 1) for (rp = lp + 1; rp < size ; rp = rp + 1) if (array[lp] > array[rp]) swap(&array[lp],&array[rp]); } void sortArrayDESC(int array[], int size) { int lp , rp; for (lp = 0 ; lp < size -1 ; lp = lp + 1) for (rp = lp + 1; rp < size ; rp = rp + 1) if (array[lp] < array[rp]) swap(&array[lp],&array[rp]); } void printArray(int array[], int size) { int i; for (i = 0 ; i < size ; i = i + 1) printf("%d ", array[i]); } void swap(int* x, int* y) { int temp; temp = *x; *x = *y ; *y = temp; }

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter16: Searching, Sorting And Vector Type
Section: Chapter Questions
Problem 20PE
icon
Related questions
Question

use c code to develop the condition and function for the following items and then redevelop the code by adding the function as shown below, the original code has been given below.

Hint: a)the function need to be made and develop  and than add to the code 1. print Reverse 2. void reverseIt 3. void search Array 4.void search array 5. void array copy and void arrayDiff) b) the answer must be include and output and c code

void printReverse(int array[], size); //prints the array reversely
void reverseIt(int array[], size); //reverses an array
void searchArray(int array[], int size, int num);
// returns the first index of the array whose value is num.
//returns -1 if the number was not found in the array
// optional for lab 6:
void searchnArray(int array[], int size, int num, int n);
// returns the nth index of the array whose value is num.
//returns -1 if the number was not found in the array
void arrayCopy (int arDest[], int arSource[], int commonSize);
// copies cells from arSourc to arDest
void arrayDiff (int ar1[], int ar2[], int commonSize);
// returns the number of differences between array elements (how many cells are different)

int main(void)
{
int ar[6]={1, 0, 2, -1, 4, 3};
int arSize = 6;
int lp , rp, i;

printf("before sort: ");
printArray(ar, arSize);
//ascending sort - increasing
sortArrayDESC(ar, arSize);
printf("\nafter sort: ");
printArray(ar, arSize);

}

void sortArrayASC(int array[], int size)
{
int lp , rp;
for (lp = 0 ; lp < size -1 ; lp = lp + 1)
for (rp = lp + 1; rp < size ; rp = rp + 1)
if (array[lp] > array[rp])
swap(&array[lp],&array[rp]);
}

void sortArrayDESC(int array[], int size)
{
int lp , rp;
for (lp = 0 ; lp < size -1 ; lp = lp + 1)
for (rp = lp + 1; rp < size ; rp = rp + 1)
if (array[lp] < array[rp])
swap(&array[lp],&array[rp]);

}

void printArray(int array[], int size)
{
int i;
for (i = 0 ; i < size ; i = i + 1)
printf("%d ", array[i]);
}

void swap(int* x, int* y)
{
int temp;
temp = *x;
*x = *y ;
*y = temp;
}

Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,