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

Okay so I\'ve been trying to get these two problems working for thelast hour or

ID: 3617606 • Letter: O

Question

Okay so I've been trying to get these two problems working for thelast hour or so and still no luck.
Please advise.
Q. SOLVED
==================================
And question #2 that has been bugging me.
Q. Write the definition of a function reverse , whosefirst parameter is an array of integers and whose second parameteris the number of elements in the array. The function reverses theelements of the array. The function does not return a value.
And my answer:
==================================
void reverse(int arr[],int i) {
int temp = 0;
int j;
for(j = 0; j < i; j++) {
temp = arr[i-1-j];
arr[i-1-j]=a[j];
a[j] = temp;
}
}
==================================

Explanation / Answer

#include<stdio.h> #include<stdlib.h>
int main(void){       int arr1[] = {1,2,3,4,5};    int arr2[] = {5,4,3,2,1};      int i = 0;       if(reverse(arr1,arr2,5) == 1){    printf("They are reverses of eachother ");       }else{    printf("They are not reverses ofeach other ");    }       system("pause");    return 0; }

//This function returns 1 for true and 0 for false; int reverse(int n[], int m[], int size){    int i;    for(i = 0; i < size; i++){    if(n[i] != m[size-i-1])    return 0;    }    return 1; }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote