Note: x = &a means x is an integer pointer which should store the address of the variable a. & is the addressOf operator. By *x, we denote the value of the variable stored at the address x. * is the valueAt operator.
Answers
(a) a = 20, b = 20.
This is because, x and y are the pointers which point to the memory locations where a and b are stored, respectively.
When you set *x = *y, it means you are assigning the variable stored in the address denoted by x (which is a) to the value of the integer stored in the address denoted by the pointer y(which is b).
Hence, both a and b would have value 20, in the end.
(b) a = 2, b = 5.
This is because, x and y are the pointers which point to the memory locations where a and b are stored, respectively.
When you set *x = *y, it means you are assigning the variable stored in the address denoted by x (which is a) to the value of the integer stored in the address denoted by the pointer y(which is b). At this point, a = 20, b = 20.
After this, you have *x = 2, i.e. you are assigning the variable stored in the address denoted by the pointer x (which is a) to 2.
Then, *y = 5, i.e. you are assigning the variable stored in the address denoted by the pointer y (which is b) to 5.
(c) a = 22, b = 19.
This is because, x and y are the pointers which point to the memory locations where a and b are stored, respectively.
When you set *x = *y, it means you are assigning the variable stored in the address denoted by x (which is a) to the value of the integer stored in the address denoted by the pointer y(which is b). At this point, a = 20, b = 20.
After this, you have *x += 2, i.e. you instruct to increase the value of the variable stored in the the address denoted by x (which is a) by 2.
Finally, you have (*y)--, i.e. you instruct to decrease the value of the variable stored in the the address denoted by y (which is b) by 1.
Suppose the following declarations and statement are m effect What are the values of and b...
8 Suppose the following declarations and statement are in effect. What are the values of x and y in each case? *p *q; = (b) int x = 1, y = 3, *m = &x, *n = &у; *n = 5; *a += 2; (8)Please solve written in details. (4)Notice the semi colon and explain. PLEASE NO CODING(both) 4 Determine the output produced by each of the following statements: (a) for (i = 6; 1 > 0;-1) print (-") (b)...
1.) Using the following declarations and a member of the Array class, int [ ] bArray = new int [10]; int location; Using a method in the Array class, write a statement that would order the values in the bArray array in ascending order. ___________________ HINT: You must write the full statement which includes a call to a method in the Array class. 2.) Using the following declarations and a member of the Array class, int [ ] bArray =...
Assume the following declarations: int b[] = {10, 20, 30}; int *x = b + 1; Choose all the expressions that are defined and evaluate to 10 A. *b B. b[1] C. *x D. x[-1] E. x[1] - b[1]
Suppose the following declarations appear in the mainfunction of a C++ program: string name, qualification; char sex; int age, yearsExperience; If the following function header is given: void findCandidate (char sex, int & agep, string & name, int yearsExperience, string qualification) which of the options below is a correct calling statement of the function findCandidate in the main function? 1. findCandidate('m', 30, nameP, 7, "B. Curr"); 2. findCandidate (sex, age, name, yearsExperience, qualification); 3. findCandidate ('m', 30, name, 7, qualification);...
1. (3% each) Given the following declarations: int a-4 int b-6: float5.0 Evaluate the following Java expressions: a) (5 + a / b) % 2- b) c / (10 % b) C) 5 * 300 7 + 8 / 3-6
After the following declarations and statements are executed: int i, j, k ; boolean c; float x, y, z; int[ ] num = {4, 1, 2, 3, 8}; i = 3; j = 5; x = 4.3; y = 58.209; c = !(i > j) ; what is the value of c
3. Identify error(s), if any in the following array declarations. If a statement is incorrect, provide the correct statement. a. Int primeNum[99]; b. Int test testScores[0]; c. String names[60]; d. Int list100[0..99]; e. Double [50] gpa; f. Const longSize = 100; Int list {2* size];
What is the output of the following statement? Suppose a and b are int variables, c is a double variable, and a = 13, b = 5, and c = 17.5. System.out.println((int)(c)% 5 + a - b); a. 10 b. 11 c. 15.5 d. 11.0
CREDITUU NAME: (8) Given the following declarations: int *pt: int size; a) Write the one statement that will dynamically allocate an integer array of size size WHICH YOU WILL WRITE TO GET USER INPUT FROM THE CONSOLE using the declarations above. b) Write the one statement that would delete the dynamically allocated array.
Which of the following are valid array declarations? a. int[] array- new int[10]; b. double [array double[10]; c. charl charArray "Computer Science"; None of the above Analyze the following code: class Test public static void main(Stringl] args) System.out.println(xMethod(10); public static int xMethod(int n) System.out.println("int"); return n; public static long xMethod(long n) System.out.,println("long"); return n The program displays int followed by 10 The program displays long followed by 10. The program does not compile. None of the above. tions 3-4 are...