. Weird Treasure Chest by CodeChum Admin I'm now in the middle of the jungle when I saw this weird treasure chest.   It seems that if I properly place the address of a certain number, I get a very weird result!   Instructions: In the code editor, you are provided with a treasureChestMagic() function which has the following description: Return type - void Name - treasureChestMagic Parameters - an address of an integer Description - updates the value of a certain integer randomly You do not have to worry about how the treasureChestMagic() function works. All you have to do is ask the user for an integer and then call the treasureChestMagic() function, passing the address of that integer you just asked. Finally, print the updated value of the integer inputted by the user. Input 1. An integer Output Enter n: 10 Treasure Chest Magic Result = 13

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

(C PROGRAMMING ONLY)

2. Weird Treasure Chest
by CodeChum Admin

I'm now in the middle of the jungle when I saw this weird treasure chest.

 

It seems that if I properly place the address of a certain number, I get a very weird result!

 

Instructions:

In the code editor, you are provided with a treasureChestMagic() function which has the following description:
Return type - void
Name - treasureChestMagic
Parameters - an address of an integer
Description - updates the value of a certain integer randomly
You do not have to worry about how the treasureChestMagic() function works. All you have to do is ask the user for an integer and then call the treasureChestMagic() function, passing the address of that integer you just asked.
Finally, print the updated value of the integer inputted by the user.
Input

1. An integer

Output

Enter n: 10
Treasure Chest Magic Result = 13

integer you just asked.
3. Finally, print the updated value of
main.c
+ c
the integer inputted by the user.
1 #include<stdio.h>
2 #include<math.h>
3
4
void treasureChestMagic(int*);
Input
int main(void) {
// TODO: Write your code here
6.
1. An integer
7
8
9.
return 0;
Output
10 }
11
12 - void treasureChestMagic(int *n) {
int temp = *n;
= temp;
Enter n: 10
13
Treasure Chest Magic Result = 13
14
int temp2
15
16
*n = *n + 5 - 5 * 5 / 5;
17
18
temp2
(int) pow(2, 3);
19
Transcribed Image Text:integer you just asked. 3. Finally, print the updated value of main.c + c the integer inputted by the user. 1 #include<stdio.h> 2 #include<math.h> 3 4 void treasureChestMagic(int*); Input int main(void) { // TODO: Write your code here 6. 1. An integer 7 8 9. return 0; Output 10 } 11 12 - void treasureChestMagic(int *n) { int temp = *n; = temp; Enter n: 10 13 Treasure Chest Magic Result = 13 14 int temp2 15 16 *n = *n + 5 - 5 * 5 / 5; 17 18 temp2 (int) pow(2, 3); 19
main.c
> + c
6 - int main(void) {
// TODO: Write your code here
8
return 0;
10 }
11
12 - void treasureChestMagic(int *n) {
int temp = *n;
int temp2 = temp;
13
14
15
16
*n = *n + 5 - 5 * 5/5;
17
18
temp2 = (int) pow(2, 3);
19
0) {
if(temp % 3 ==
* 10;
} else if(temp % 10
n = temp + 3;
} else if(temp % 11
*n = temp - 5;
20
21
'n = temp
22
0) {
23
%3D
24
0) {
25
}
27 }
26
Transcribed Image Text:main.c > + c 6 - int main(void) { // TODO: Write your code here 8 return 0; 10 } 11 12 - void treasureChestMagic(int *n) { int temp = *n; int temp2 = temp; 13 14 15 16 *n = *n + 5 - 5 * 5/5; 17 18 temp2 = (int) pow(2, 3); 19 0) { if(temp % 3 == * 10; } else if(temp % 10 n = temp + 3; } else if(temp % 11 *n = temp - 5; 20 21 'n = temp 22 0) { 23 %3D 24 0) { 25 } 27 } 26
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY