Please help me by pointing me to the correct address. main.c 1 #include 2 Instructions: 3 int main(void) { int n; 1. In the code editor, you are provided with a main() code that asks for an integer input from the user and stores this to the variable n. 2. Your task is to set the value of the destination_ptr found at line 9 to the address of the variable n. printf("Enter the destination number: "); scanf("%d", &n); 7 // TODO: Assign the address of n to this pointer int *destination_ptr; 8 10 3. Aside from this, do not edit anything else. 11 12 if(*destination_ptr == n) { printf("Found it!"); } else { printf("Hmm, something's not right"); } 13 Input 14 15 1. An integer value 16 17 18 Output 19 return 0; 20 }. Enter the destination number: 2 Found it!

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 19SA
icon
Related questions
Question

(C Language) Topic: Pointers

main.c
Please help me by pointing me to the correct address.
1 #include<stdio.h>
2
Instructions:
3 int main(void) {
int n;
printf("Enter the destination number: ");
scanf("%d", &n);
4
1. In the code editor, you are provided with a main()
code that asks for an integer input from the user
and stores this to the variable n.
2. Your task is to set the value of the destination_ptr
found at line 9 to the address of the variable n.
7
// TODO: Assign the address of n to this pointer
int *destination_ptr;
8.
10
3. Aside from this, do not edit anything else.
11
12
if(*destination_ptr == n) {
printf("Found it!");
} else {
printf("Hmm, something's not right");
}
13
Input
14
15
1. An integer value
16
17
18
Output
19
return 0;
20 }.
Enter the destination number: 2
Found it!
Transcribed Image Text:main.c Please help me by pointing me to the correct address. 1 #include<stdio.h> 2 Instructions: 3 int main(void) { int n; printf("Enter the destination number: "); scanf("%d", &n); 4 1. In the code editor, you are provided with a main() code that asks for an integer input from the user and stores this to the variable n. 2. Your task is to set the value of the destination_ptr found at line 9 to the address of the variable n. 7 // TODO: Assign the address of n to this pointer int *destination_ptr; 8. 10 3. Aside from this, do not edit anything else. 11 12 if(*destination_ptr == n) { printf("Found it!"); } else { printf("Hmm, something's not right"); } 13 Input 14 15 1. An integer value 16 17 18 Output 19 return 0; 20 }. Enter the destination number: 2 Found it!
main.c
< >
+
Instructions:
1 #include<stdio.h>
2
1. In the code editor, there are three things present:
1. An integer value representing the next
3 int main(void) {
int next_destination = 10;
4
destination
5
2. Pointer #1 which represents the first signage
int *pointer_1, *pointer_2;
6
3. And Pointer #2 which represents the second
signage
7
8
// TODO: Perform instruction 2.a
2. For this problem, you need to do two things:
1. Assign the address of the integer value (or the
next_destination) to Pointer #2
10
11
// TODO: Perform instruction 2.b
12
2. Assign the value of Pointer #2 to Pointer #1
3. Using Pointer #1 and the dereferencing
13
14
// TODO: Perform instruction 2.c
operator, print the value of the
15
next destination
16
17
return 0;
18 }.
Output
Next destination = 20
Transcribed Image Text:main.c < > + Instructions: 1 #include<stdio.h> 2 1. In the code editor, there are three things present: 1. An integer value representing the next 3 int main(void) { int next_destination = 10; 4 destination 5 2. Pointer #1 which represents the first signage int *pointer_1, *pointer_2; 6 3. And Pointer #2 which represents the second signage 7 8 // TODO: Perform instruction 2.a 2. For this problem, you need to do two things: 1. Assign the address of the integer value (or the next_destination) to Pointer #2 10 11 // TODO: Perform instruction 2.b 12 2. Assign the value of Pointer #2 to Pointer #1 3. Using Pointer #1 and the dereferencing 13 14 // TODO: Perform instruction 2.c operator, print the value of the 15 next destination 16 17 return 0; 18 }. Output Next destination = 20
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Fundamentals of Computer System
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