Instructions: 1 #include 2 #include 1. In the code editor, you are provided with a treasureChestMagic() function which has 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 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. 3 4 void treasureChestMagic(int*); 5 6 int main(void) { 7 // TODO: Write your code here 8 return e; 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 == ®) { *n = temp * 10; } else if(temp % 10 == e) { *n = temp + 3; } else if(temp % 11 == e) { *n = temp 20 21 22 Enter n: 10 23 Treasure Chest Magic Result = 13 24 25 5; 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
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 }
main.c
Instructions:
1 #include<stdio.h>
1. In the code editor, you are provided with a main() function that asks the user for 3
2
integers.
3 int main(void) {
int a, b, c;
2. Your task is to create 3 pointers and name them: a_ptr, b_ptr, and c_ptr. Then, assign
4
the address of a to a_ptr, b to b_ptr, c to c_ptr. Make sure to do this before the printf
printf("Enter a: ");
scanf("%d", &a);
printf("Enter b: ");
scanf("%d", &b);
printf("Enter c: ");
scanf("%d", &c);
statement found at line 16.
6.
7
8.
9.
Input
10
11
1. First integer
12
2. Second integer
13
// TODO: Write your answer here
14
3. Third integer
15
16
printf("Total = %d", *a_ptr + *b_ptr + *c_ptr);
17
Output
18
return 0;
19
Enter a: 1
Enter b: 6
Enter c: ·3
Total = 10
Transcribed Image Text:main.c Instructions: 1 #include<stdio.h> 1. In the code editor, you are provided with a main() function that asks the user for 3 2 integers. 3 int main(void) { int a, b, c; 2. Your task is to create 3 pointers and name them: a_ptr, b_ptr, and c_ptr. Then, assign 4 the address of a to a_ptr, b to b_ptr, c to c_ptr. Make sure to do this before the printf printf("Enter a: "); scanf("%d", &a); printf("Enter b: "); scanf("%d", &b); printf("Enter c: "); scanf("%d", &c); statement found at line 16. 6. 7 8. 9. Input 10 11 1. First integer 12 2. Second integer 13 // TODO: Write your answer here 14 3. Third integer 15 16 printf("Total = %d", *a_ptr + *b_ptr + *c_ptr); 17 Output 18 return 0; 19 Enter a: 1 Enter b: 6 Enter c: ·3 Total = 10
Expert Solution
steps

Step by step

Solved in 4 steps with 3 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,