Demonstrate the use of pointers In C language.

Nov 30th, 2014
Anonymous
Category:
Calculus
Price: $5 USD

Question description

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.

I need help to fix my code:

#include<stdio.h>

main()

{

int d=0, *dPtr;

char c; 

dPtr=&d;

printf("Menu Options:\n");

printf("a. a new integer value.\n");

printf("b. a pointer address.\n");

printf("c. the address of an integer.\n");

printf("d. the value of an integer.\n");

scanf("%c", &c);

switch(c){

case 'a':

printf("Enter an integer:");

scanf("%d", &d);

break;

case 'b':

printf("%p", dPtr);

break;

case 'c':

printf("%p", &d);

break;

case 'd':

printf("%d\n", d);

break;

}

}


Tutor Answer

(Top Tutor) kukistars
School: UCLA

Studypool has helped 1,244,100 students

Review from student
Anonymous
" Top quality work from this guy! I'll be back! "
Ask your homework questions. Receive quality answers!

Type your question here (or upload an image)

1820 tutors are online

Brown University





1271 Tutors

California Institute of Technology




2131 Tutors

Carnegie Mellon University




982 Tutors

Columbia University





1256 Tutors

Dartmouth University





2113 Tutors

Emory University





2279 Tutors

Harvard University





599 Tutors

Massachusetts Institute of Technology



2319 Tutors

New York University





1645 Tutors

Notre Dam University





1911 Tutors

Oklahoma University





2122 Tutors

Pennsylvania State University





932 Tutors

Princeton University





1211 Tutors

Stanford University





983 Tutors

University of California





1282 Tutors

Oxford University





123 Tutors

Yale University





2325 Tutors