Question: / * * An exercise to help you understand the use of pointer variables. * / #include int main ( void ) { int foo;

/*
* An exercise to help you understand the use of pointer variables.
*/
#include
int main(void)
{
int foo;
int bar;
int *fred;
int *sam;
bar =100;
foo =200;
fred = &foo;
/* point one */
printf("point one: foo is %d and bar is %d.
", foo, bar);
sam = &bar;
*sam +=30;
*fred -=40;
/* point two */
printf("point two: foo is %d and bar is %d.
", foo, bar);
fred = &bar;
*fred +=5;
/* point three */
printf("point three: foo is %d and bar is %d.
", foo, bar);
printf("point three: *fred is %d and *sam is %d.
",*fred,*sam);
sam = &foo;
*sam =*fred;
/* point four */
printf("point four: foo is %d and bar is %d.
", foo, bar);
*sam *=100;
sam = fred;
/* point five */
printf("point five: foo is %d and bar is %d.
", foo, bar);
printf("point five: *fred is %d and *sam is %d.
",*fred,*sam);
return 0;
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!