main.c Instructions: 1. In the code editor, you are provided with a treasureChestMagic() function which has 1 #include 2 #include the following description: 1. Return type - void 2. Name - treasureChestMagic 3. Parameters - an address of an integer 4. Description - updates the value of a certain integer randomly 3 4 void treasureChestMagic (int*); 5. 6 int main(void) { // TODO: Write your code here 8. 2. You do not have to worry about how the treasureChestMagic() function works. All you 9. return e; have to do is ask the user for an integer and then call the treasureChestMagic() 10 } function, passing the address of that integer you just asked. 3. Finally, print the updated value of the integer inputted by the user. 11 12 void treasureChestMagic(int *n) { int temp = *n; int temp2 = temp; 13 14 Input 15 *n = *n + 5 - 5 * 5 / 5; 16 17 1. An integer 18 temp2 = (int) pow(2, 3); 19 Output if(temp % 3 == 0) { *n = temp * 10; } else if(temp % 10 == e) { *n = temp + 3; } else if(temp % 11 == 0) { *n = temp - 5; 20 21 22 Enter n: 10 23 Treasure Chest Magic Result = 13 24 25 26

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter12: Points, Classes, Virtual Functions And Abstract Classes
Section: Chapter Questions
Problem 1TF
icon
Related questions
Question

C language

 

Output:

Enter n: 10

Treasure Chest Magic Result = 13

main.c
> + c
Instructions:
1 #include<stdio.h>
1. In the code editor, you are provided with a treasureChestMagic() function which has
2 #include<math.h>
the following description:
1. Return type - void
2. Name - treasureChestMagic
4 void treasureChestMagic(int*);
6 int main(void) {
// TODO: Write your code here
3. Parameters - an address of an integer
7
4. Description - updates the value of a certain integer randomly
2. 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.
3. Finally, print the updated value of the integer inputted by the user.
8.
return 0;
10 }
11
12 void treasureChestMagic(int *n) {
int temp = *n;
int temp2 = temp;
13
14
Input
15
16
*n = *n + 5 - 5 * 5 / 5;
17
1. An integer
18
temp2 = (int) pow(2, 3);
19
Output
if(temp % 3 == 0) {
*n = temp
} else if(temp % 10 == 0) {
*n = temp + 3;
} else if(temp % 11 == 0) {
*n = temp - 5;
}
20
21
* 10;
22
Enter n: 10
23
Treasure Chest Magic Result = 13
24
25
26
27 }
Transcribed Image Text:main.c > + c Instructions: 1 #include<stdio.h> 1. In the code editor, you are provided with a treasureChestMagic() function which has 2 #include<math.h> the following description: 1. Return type - void 2. Name - treasureChestMagic 4 void treasureChestMagic(int*); 6 int main(void) { // TODO: Write your code here 3. Parameters - an address of an integer 7 4. Description - updates the value of a certain integer randomly 2. 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. 3. Finally, print the updated value of the integer inputted by the user. 8. return 0; 10 } 11 12 void treasureChestMagic(int *n) { int temp = *n; int temp2 = temp; 13 14 Input 15 16 *n = *n + 5 - 5 * 5 / 5; 17 1. An integer 18 temp2 = (int) pow(2, 3); 19 Output if(temp % 3 == 0) { *n = temp } else if(temp % 10 == 0) { *n = temp + 3; } else if(temp % 11 == 0) { *n = temp - 5; } 20 21 * 10; 22 Enter n: 10 23 Treasure Chest Magic Result = 13 24 25 26 27 }
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Function Arguments
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
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,