Question

In: Computer Science

Explain an example in which a variable has two different addresses at different places in a...

Explain an example in which a variable has two different addresses at different places in a program.

Solutions

Expert Solution

  • NOTE : I have used C Language to show this
  • Explanation :-
  • As in the question asked that to show an example in which a variable has two Different addresses at Different places in a program.
  • I choose C language to show this
  • we can use Pointer variable in C to show two different addresses at Different places in a program
  • Here in this example we will use a single variable to show two different addresses at different places in a program
  • I have used comments to explain the code
  • CODE :-

      #include<stdio.h>

      int main(){

           int x=2,y;

           y=3;

           int *ptr; //Here we use *ptr a pointer variable to show the different addresses in a program

           ptr = &x; // Here we are taking x address to the pointer variable *ptr

           printf("%x\n",ptr); //Here we are printing the *ptr means pointer variable address

           ptr = &y; // Here we are taking y address to the pointer variable *ptr

               printf("%x\n",ptr); //Here we are printing the *ptr means pointer variable address

             

/*Here we have used a one single pointer variable *ptr in two different places to get two different addresses in a program. so, It is possible to get two different addresses in two different places in a program. */

}

  • CODE : -

  • OUTPUT :-

  • Here,The output shows us that we can have two different addresses at different places in a program with single variable(as i have used the pointer variable)

Thank You...!


Related Solutions

1. Explain the difference between a mediator variable and a moderator variable. Which of the two...
1. Explain the difference between a mediator variable and a moderator variable. Which of the two is more commonly seen in resilience research and why?
Which of the following is an example of the law of multiple proportions? two different samples...
Which of the following is an example of the law of multiple proportions? two different samples of table salt are found to have the same ratio sodium to chlorine carbon dioxide always has the same mass ratio a sample of chlorine is found to contain three times as mush 35Cl as 37Cl. two different compounds formed from nitrogen and oxygen have the following mass ratio: 1g N: 2.28 g O and 2g N : 2.28 g O
T-SHIRTS A school organization has found four different places from which they may place order of...
T-SHIRTS A school organization has found four different places from which they may place order of t-shirts. Each function below could represent the cost of placing a t-shirt order as a function of the number of t-shirts purchased. c represents cost in dollars, t represents # of t-shirts. A) c = 5t B) c =3.25t + 55 C) c =3t + 100 D) c =6t - 55 DIRECTIONS FOR THE T-SHIRTS PROBLEM Graph each function (equation) • Graph all four...
The kidneys handle Na+ in different places of the nephron. Which statement is correct? Water is...
The kidneys handle Na+ in different places of the nephron. Which statement is correct? Water is filtered out of glomerular capillaries by bulk flow. Water is actively reabsorbed from the proximal tubule, and Na+ follows down its diffusion gradient. The permeability of the ascending limb of the loop of Henle is modified by vasopressin. Vasopressin inserts pumps in the collecting duct membrane that move water against its concentration gradient.
When a business/firm grows and has their data in different places and on different documents/spreadsheets, why...
When a business/firm grows and has their data in different places and on different documents/spreadsheets, why is integrating data so important to the business/firm?
give an example of pure rolling ,which is combination of two linear motion,with an example???explain answer...
give an example of pure rolling ,which is combination of two linear motion,with an example???explain answer with daigrammm i posted it twice,dont give answer untill u r not sure..
Question: Give an example of a hypergeometric random variable for which a binomial random variable is...
Question: Give an example of a hypergeometric random variable for which a binomial random variable is NOT a good approximation. You must describe each of the following: i. the experiment ii. a random variable X from the experiment and what X represents iii. the probability mass function (PMF) of X iv. a binomial random variable that approximates X and its parameters v. the PMF of the binomial random variable and why it's a good estimate of the PMF of X
For each of the following research situations, write a sentence or two to explain which variable...
For each of the following research situations, write a sentence or two to explain which variable more naturally plays the role of X (the independent, or explanatory, variable) and which plays the role of Y (the dependent, or response, variable) – or whether the direction of the relationship is not clear. (2 points each) For a population of home-owning families: the family’s annual income the assessed value of the home they live in For the population of occupations represented in...
With example, explain the different types of attack surface?
With example, explain the different types of attack surface?
9. The CAA dealt with both stratospheric and tropospheric ozone issues. Explain which sections addresses which...
9. The CAA dealt with both stratospheric and tropospheric ozone issues. Explain which sections addresses which issue and how these two issues are addressed. (SHORT ESSAY)
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT