Duplicate Question
The question on this page has been marked as a duplicate question.
Original Question
Build a program that allows a user to select one of the following four menu options: enter new integer value, print pointer add...Asked by Poohboi
: Build a program that allows a user to select one of the following four menu options: enter new integer value, print pointer address, print integer address, and print integer value. For this program you will need to create two variables: one integer data type and one pointer. Using indirection, assign any new integer value entered by the user through an appropriate pointer.
Answers
Answered by
Poohboi
Need know if this is right please helps anyone.
include <stdio.h>
#include <stdlib.h>
int main(){
int d, *dPtr;
char c;
int=0;
dPtr=&d;
printf("Choose one of the following:\n");
printf("a. enter a new integer value.\n");
printf("b. print a pointer address.\n");
printf("c. print the address of an integer.\n");
printf("d. print the value of an integer.\n");
scanf("%c", &c);
switch (c){
case 'a':
printf("Enter a number:");
scanf("%d, &d);
break;
case 'b':
printf("%p", dPtr);
break;
case 'c':
printf("%p", &d);
break;
case 'd':
printf("%d\n", d);
break;
}
return 0;
}
include <stdio.h>
#include <stdlib.h>
int main(){
int d, *dPtr;
char c;
int=0;
dPtr=&d;
printf("Choose one of the following:\n");
printf("a. enter a new integer value.\n");
printf("b. print a pointer address.\n");
printf("c. print the address of an integer.\n");
printf("d. print the value of an integer.\n");
scanf("%c", &c);
switch (c){
case 'a':
printf("Enter a number:");
scanf("%d, &d);
break;
case 'b':
printf("%p", dPtr);
break;
case 'c':
printf("%p", &d);
break;
case 'd':
printf("%d\n", d);
break;
}
return 0;
}
There are no AI answers yet. The ability to request AI answers is coming soon!
Submit Your Answer
We prioritize human answers over AI answers.
If you are human, and you can answer this question, please submit your answer.