. 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
(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](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fd46b6080-59ac-43dd-a083-17cb326bb723%2Fb322b117-a8e7-4370-adb7-b3e6aa04496f%2Farp6sy8_processed.jpeg&w=3840&q=75)
![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](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fd46b6080-59ac-43dd-a083-17cb326bb723%2Fb322b117-a8e7-4370-adb7-b3e6aa04496f%2Fbx9vj8i_processed.jpeg&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 3 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)