someone help me modify the code please. Instructions: In the code editor, you are provided with the main() function that asks the user for 10 elements that represents the options for the ring as well as a single integer value that represents the ring that she wants. Then, a call to the findRing() function is made and the array of rings and the ring she wants are passed into it. Your task is to implement the findRing() function. This has the following details: Return type - int Name - findRing Parameters int* - for the array of rings int - size of the array of rings int - the ring that she wants Return value - the index of the ring in the array of rings. It is guaranteed that there is only one such ring that matches the ring that she wants. Input 1. Ten integer values representing the rings 2. Integer value representing the ring she wants   #include int findRing(int rings[],int n,int wantedRing) {int index=0;     for(int i=0;i

Operations Research : Applications and Algorithms
4th Edition
ISBN:9780534380588
Author:Wayne L. Winston
Publisher:Wayne L. Winston
Chapter17: Markov Chains
Section17.5: Steady-state Probabilities And Mean First Passage Times
Problem 14P
icon
Related questions
Question

someone help me modify the code please.

Instructions:

  1. In the code editor, you are provided with the main() function that asks the user for 10 elements that represents the options for the ring as well as a single integer value that represents the ring that she wants. Then, a call to the findRing() function is made and the array of rings and the ring she wants are passed into it.
  2. Your task is to implement the findRing() function. This has the following details:
    1. Return type - int
    2. Name - findRing
    3. Parameters
      1. int* - for the array of rings
      2. int - size of the array of rings
      3. int - the ring that she wants
    4. Return value - the index of the ring in the array of rings. It is guaranteed that there is only one such ring that matches the ring that she wants.

Input

1. Ten integer values representing the rings

2. Integer value representing the ring she wants

 

#include <stdio.h>
int findRing(int rings[],int n,int wantedRing)
{int index=0;
    for(int i=0;i<n;i++)
    {
        if(rings[i]==wantedRing)//Performing a linear search to find the wanted ring
        {
          index=i;
        }
    }
    return index;
}
int main() {
   int rings[10];

    for(int i = 0; i <10; i++) {
        printf("Enter option #%d: ", i + 1);
        scanf("%d", &rings[i]);
    }

    int wantedRing;
    printf("Enter the ring she wants: ");
    scanf("%d", &wantedRing);

    printf("\nRing %d found at option %d!", wantedRing, findRing(rings, 10, wantedRing) + 1);

    return 0;
    
}

E Run Tests
O Test Case 1
Your Output
Enter option 1: 5
Enter option 2: 3
Enter option 43: 10
Enter option H4: 9
Enter option 45: 13
Enter option 16: 11
Enter option 47: 20
Enter option 18: 25
Enter option 19: 4
Enter option 1e: 3
Enter the ring she wants: 25
Ring 25 found at option 8!
Expected Output
Enter option 1: 5
Enter option 2: 3
Enter option H3: 18
Enter option 14: 9
Enter option 15: 13
Enter option 16: 11
Enter option 17: 20
Enter option u8: 25
Enter option 19: 4
Enter option 10: 3
Enter the ring she wants: 25
Ring 25 is found at option 8!
Transcribed Image Text:E Run Tests O Test Case 1 Your Output Enter option 1: 5 Enter option 2: 3 Enter option 43: 10 Enter option H4: 9 Enter option 45: 13 Enter option 16: 11 Enter option 47: 20 Enter option 18: 25 Enter option 19: 4 Enter option 1e: 3 Enter the ring she wants: 25 Ring 25 found at option 8! Expected Output Enter option 1: 5 Enter option 2: 3 Enter option H3: 18 Enter option 14: 9 Enter option 15: 13 Enter option 16: 11 Enter option 17: 20 Enter option u8: 25 Enter option 19: 4 Enter option 10: 3 Enter the ring she wants: 25 Ring 25 is found at option 8!
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 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
Operations Research : Applications and Algorithms
Operations Research : Applications and Algorithms
Computer Science
ISBN:
9780534380588
Author:
Wayne L. Winston
Publisher:
Brooks Cole