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; }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education