Hi! I would like to ask if how can I implement my findRing() function here.   There's 2 constraints given which are the code should call the 'findRing' in main and the code should implement 'findring' function.   The entire codes were working I just don't know how to implement the findRing function here. Thank you so much!

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
100%

Hi! I would like to ask if how can I implement my findRing() function here.

 

There's 2 constraints given which are the code should call the 'findRing' in main and the code should implement 'findring' function.

 

The entire codes were working I just don't know how to implement the findRing function here.

Thank you so much!

main.c
+ c
Tests
2. Find the ring!
1 #include<stdio.h>
2
3 // TODO: Declare the findRingO here
void printElements(int*, int, int);
by CodeChum Admin
E Run Tests
Thanks to you, my crush was impressed with my awesome display() function!!
4.
6 int main(void)
7
8 - {
Constraints
I'm now planning to propose to her, but I need to find the best ring available in the
market as she is truly special to me.
int rings[10];
int findRing, i;
O Constraint 1
The code should call 'findRing in main,
10
11
12 -
13
Can you help me find the ring that she wants?
for( i = 0; i < 10; i++) {
printf("Enter option #%d: ", i + 1);
scanf("%d", &rings[i]);
Instructions:
14
O Constraint 2
15
16
17
18
19
20
21
22
23
24
25
26 }
27
28 // TODO: Define the findRing() here
1. In the code editor, you are provided with the main() function that asks the
The code should implement findRing' function.
int wantedRing;
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
Test Cases
printf("Enter the ring she wants: ");
scanf("%d", &wantedRing);
passed into it.
2. Your task is to implement the findRing() function. This has the following
printElements(rings, wantedRing, i);
O Test Case 1
details:
1. Return type - int
Your Output
return i;
2. Name - findRing
3. Parameters
Enter option #1: 5
1. int - for the array of rings
2. int - size of the array of rings
Enter option #2: 3
29
30 void printElements (int *rings, int "wante dRing, int i)
31-
32
33
34 -
35
36 -
37
38
39
Enter option #3: 10
3, int - the ring that she wants
Enter option #4: 9
4. Return value - the index of the ring in the array of rings. It is guaranteed
Enter option #5: 13
for (i = 0; i < 10; i++)
{
if (rings[i] = wantedRing)
that there is only one such ring that matches the ring that she wants.
Enter option #6: 11
Enter option #7: 20
Enter option #8: 25
Input
printf("\nRing %d is found at option %d!", wantedRing, i+ 1);
Enter option #9: 4
Enter option #10: 3
Enter the ring she wants: 25
1. Ten integer values representing the rings
40
2. Integer value representing the ring she wants
41
Ring
is found at option 8!
Output
Expected Output
Enter option #1: 5
Enter option #1: 5
Enter option #2: 3
Enter option #2: 3
Enter option #3: 10
Enter option #3: 10
Enter option #4: 9
Enter option #4: 9
Enter option #5: 13
Enter option #5: 13
Enter option #6: 11
Enter option #6: 11
Enter option #7: 20
Enter option #7: 20
Enter option #8: 25
Enter option #8: 25
Enter option #9: 4
Enter option #9: 4
Enter option #10: 3
Enter option #10: 3
Enter the ring she wants: 25
Enter the ring she wants: 25
Ring 25 is found at option 8!
Ring 25 is found at option 8!
Score: 0/10
Transcribed Image Text:main.c + c Tests 2. Find the ring! 1 #include<stdio.h> 2 3 // TODO: Declare the findRingO here void printElements(int*, int, int); by CodeChum Admin E Run Tests Thanks to you, my crush was impressed with my awesome display() function!! 4. 6 int main(void) 7 8 - { Constraints I'm now planning to propose to her, but I need to find the best ring available in the market as she is truly special to me. int rings[10]; int findRing, i; O Constraint 1 The code should call 'findRing in main, 10 11 12 - 13 Can you help me find the ring that she wants? for( i = 0; i < 10; i++) { printf("Enter option #%d: ", i + 1); scanf("%d", &rings[i]); Instructions: 14 O Constraint 2 15 16 17 18 19 20 21 22 23 24 25 26 } 27 28 // TODO: Define the findRing() here 1. In the code editor, you are provided with the main() function that asks the The code should implement findRing' function. int wantedRing; 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 Test Cases printf("Enter the ring she wants: "); scanf("%d", &wantedRing); passed into it. 2. Your task is to implement the findRing() function. This has the following printElements(rings, wantedRing, i); O Test Case 1 details: 1. Return type - int Your Output return i; 2. Name - findRing 3. Parameters Enter option #1: 5 1. int - for the array of rings 2. int - size of the array of rings Enter option #2: 3 29 30 void printElements (int *rings, int "wante dRing, int i) 31- 32 33 34 - 35 36 - 37 38 39 Enter option #3: 10 3, int - the ring that she wants Enter option #4: 9 4. Return value - the index of the ring in the array of rings. It is guaranteed Enter option #5: 13 for (i = 0; i < 10; i++) { if (rings[i] = wantedRing) that there is only one such ring that matches the ring that she wants. Enter option #6: 11 Enter option #7: 20 Enter option #8: 25 Input printf("\nRing %d is found at option %d!", wantedRing, i+ 1); Enter option #9: 4 Enter option #10: 3 Enter the ring she wants: 25 1. Ten integer values representing the rings 40 2. Integer value representing the ring she wants 41 Ring is found at option 8! Output Expected Output Enter option #1: 5 Enter option #1: 5 Enter option #2: 3 Enter option #2: 3 Enter option #3: 10 Enter option #3: 10 Enter option #4: 9 Enter option #4: 9 Enter option #5: 13 Enter option #5: 13 Enter option #6: 11 Enter option #6: 11 Enter option #7: 20 Enter option #7: 20 Enter option #8: 25 Enter option #8: 25 Enter option #9: 4 Enter option #9: 4 Enter option #10: 3 Enter option #10: 3 Enter the ring she wants: 25 Enter the ring she wants: 25 Ring 25 is found at option 8! Ring 25 is found at option 8! Score: 0/10
Expert Solution
steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Concept of pointer parameter
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
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