You want a function which takes two arrays a and b which are both of the same length n and determines if they are "reversals" of each other. return 1 if a is the reverse of b (and vice-versa) return 0 otherwise. examples: (1, 3, 3, 4) is the reverse of {4, 3, 3, 1} (9, 8, 2, 2, 1, 9) is the reverse of (9, 1, 2, 2, 8, 9) Your job: write the function! Skeleton given below. int rev_eq(int a[], int b[], int n) {

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
Please the code must be in c program
## Question 5

You want a function which takes two arrays `a` and `b` which are both of the same length `n` and determines if they are "reversals" of each other.
- Return 1 if `a` is the reverse of `b` (and vice-versa).
- Return 0 otherwise.

**Examples:**
- `{1, 3, 3, 4}` is the reverse of `{4, 3, 3, 1}`
- `{9, 8, 2, 2, 1, 9}` is the reverse of `{9, 1, 2, 2, 8, 9}`

**Your job:** Write the function! Skeleton given below:

```c
int rev_eq(int a[], int b[], int n) {

}
```

**Instructions:**
Implement the function `rev_eq` to check if the array `a` is the reverse of array `b`.
Transcribed Image Text:## Question 5 You want a function which takes two arrays `a` and `b` which are both of the same length `n` and determines if they are "reversals" of each other. - Return 1 if `a` is the reverse of `b` (and vice-versa). - Return 0 otherwise. **Examples:** - `{1, 3, 3, 4}` is the reverse of `{4, 3, 3, 1}` - `{9, 8, 2, 2, 1, 9}` is the reverse of `{9, 1, 2, 2, 8, 9}` **Your job:** Write the function! Skeleton given below: ```c int rev_eq(int a[], int b[], int n) { } ``` **Instructions:** Implement the function `rev_eq` to check if the array `a` is the reverse of array `b`.
Expert Solution
Step 1 Code

int rev_eq(int a[], int b[], int n){
    // iteration for n times
    for(int i=0; i<n; i++){
        // check if ith index of array a from starting is not equal 
        // ith index of array b from last
        if(a[i]!=b[n-i-1]){
            // if not equal.. means array is not reverse. return 0
            return 0;
        }
    }
    // if array a is revese equivalent to array b. return 1
    return 1;
}

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Arrays
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