Question

In: Computer Science

C++ 3a)Assume you have an integer pointer variable named intpoint2. It contains the address 1e6f24. You...

C++

3a)Assume you have an integer pointer variable named intpoint2. It contains the address 1e6f24. You execute intpoint2++. What does intpoint2 now contain?

a)1e6f24

b)1e6f25

c)1e6f28

d)1e6f2c


3b)You have an array of integers:

int myints[10];

and the address of the first integer is be4350. What is the address of myints[1]? myints[2]?You have an array of integers:

int myints[10];

and the address of the first integer is be4350. What is the address of myints[1]? myints[2]?

a)Both are b34350

b)be4350 and b34354

c)be4354 and be4358

d)be4350 and be4358





3c)You have an array of integers:

long long int myints2[100];

and the address of the first integer is 546bb8. What is the address of myints2[1]? myints2[2]?

Group of answer choices

a)546bc0 and 546bc8

b)546bca and 546bcc

c)546bbc and 546bc0

d)546bbc and 546bc4



3d)Code a call to the function anotherFunc passing the array myints.

a)anotherFunc(myints []);

b)anotherFunc(int myints);

c)anotherFunc(myints &);

d)anotherFunc(myints);

3e)Code the function definition for anotherFunc, picking up the array myints. anotherFunc has no return value.

a)void anotherFunc (int myints []);

b)void anotherFunc (int myints * []);

c)void anotherFunc (int myints * & []);

d)void anotherFunc (int myints & []);

3f)How can the function anotherFunc change the contents of the second element of myints?

a)myints[2] = something

b)*myints [2] = something

c)myints [2] = & something

d)myints [1] = something

3g)If anotherFunc does change the contents of the second element of myints, what happens to the second element of myints in the calling program?

a)Nothing.

b)It changes to whatever the function changed it to.

c)It depends on the compiler.

d)It changes only if the defined types match.

3h)Allocate memory for an integer array with 500 elements. Use a pointer variable named q that has already been defined.

a)int q [500];

b)q = new int [500];

c)new q = int [500];

d)new q = 500 int;





3i)Set the first two elements of the new array to 5.

a)q[0] = 5; q[1] = 5;

b)q[0] = *5; q[1] = *5;

c)&q[0] = 5; &q[1] = 5;

d)*q[0] = 5; *q[1] = 5;


Solutions

Expert Solution

3a)Assume you have an integer pointer variable named intpoint2. It contains the address 1e6f24. You execute intpoint2++. What does intpoint2 now contain?

Ans C) 1e6f28

Explanation: integer pointer allocates 4byte memory to each address so when we increase intpoint2++

it allocates new 4 byte memory to new address

3b)You have an array of integers:

int myints[10];

and the address of the first integer is be4350. What is the address of myints[1]? myints[2]?

Ans. c)be4354 and be4358

expanation: each address allocated 4 byte memory so,

myints[0] = be4350

myints[1] = be4350 + 4 = be4354

myints[2] = be4354 + 4 = b34358

3c)You have an array of integers:

long long int myints2[100];

and the address of the first integer is 546bb8. What is the address of myints2[1]? myints2[2]?

Group of answer choices

Ans a)546bc0 and 546bc8

expalanation: it allocates 8 byte to each address

myints[0] = 546bb8

myints[1] = 546bb8 + 8 = 546bc0

myints[1] = 546bc0 + 8 = 546bc8

3d)Code a call to the function anotherFunc passing the array myints.

Ans d)anotherFunc(myints);

expalanation: we have to just array name in function call

3e)Code the function definition for anotherFunc, picking up the array myints. anotherFunc has no return value.

Ans void anotherFunc (int myints []);

explanation: void so no return value and int myints[] is coorect declaration of 1d array

3f)How can the function anotherFunc change the contents of the second element of myints?

Ans d)myints [1] = something

expalanation: array index starts from 0

3g)If anotherFunc does change the contents of the second element of myints, what happens to the second element of myints in the calling program?

Ans. b)It changes to whatever the function changed it to.

Expalantion: it replaces

3h)Allocate memory for an integer array with 500 elements. Use a pointer variable named q that has already been defined.

Ans. b)q = new int [500];

expanation: we donot need to put * before pointer if we declare already

3i)Set the first two elements of the new array to 5.

Ans. a)q[0] = 5; q[1] = 5;

Expanation: pointer works same like array we can access its elements by using index

/* PLEASE UPVOTE */


Related Solutions

In C++ Create a dynamic array of 100 integer values named myNums. Use a pointer variable...
In C++ Create a dynamic array of 100 integer values named myNums. Use a pointer variable (like ptr) which points to this array. Use this pointer variable to initialize the myNums array from 2 to 200 and then display the array elements. Delete the dynamic array myNums at the end. You just need to write part of the program.
write a function named as cubeCalculator that takes an integer pointer as function and return its...
write a function named as cubeCalculator that takes an integer pointer as function and return its cube value , you are required to compute the cube of a number using pointer notation , return the result as an integer value , use c++
. Assume that a double variable named alpha contains the value of an angle in radians....
. Assume that a double variable named alpha contains the value of an angle in radians. Compose a C++ statement that will display the sine of the angle so that it occupies 12 positions on the screen and displays 3 digits after the decimal point.
Using C# Create a class named Inches To Feet. Its Main()method holds an integer variable named...
Using C# Create a class named Inches To Feet. Its Main()method holds an integer variable named inches to which you will assign a value. Create a method to which you pass inches. The method displays inches in feet and inches. For example, 67 inches is 5 feet 7 inches.
Create a class using C# named InchesToFeet. Its Main()method holds an integer variable named inches to...
Create a class using C# named InchesToFeet. Its Main()method holds an integer variable named inches to which you will assign a value. Create a method to which you pass inches. The method uses 2 ref parameters: feet, inches left of type int and a parameter that is not ref of type int to which you pass inchesinches. For example, 67 inches is 5 feet 7 inches.
Assume you have a variable, budget, that is associated with a positive integer. Assume you have another variable, shopping_list, that is a tuple of strings representing items to purchase in order of priority.
Assume you have a variable, budget, that is associated with a positive integer. Assume you have another variable, shopping_list, that is a tuple of strings representing items to purchase in order of priority. (For example: ("codelab", "textbook", "ipod", "cd", "bike")) Furthermore, assume you have a variable, prices that is a dictionary that maps items (strings such as those in your shopping_list) to positive integers that are the prices of the items. Write the necessary code to determine the number of...
Create a random number generator object named myRandom and an integer variable named intRoulette. Set intRoulette...
Create a random number generator object named myRandom and an integer variable named intRoulette. Set intRoulette to be a random number from 0 to 36 (including the numbers 0 and 36). (visual studios 2015) using tryparse
Define a class named Document that contains an instance variable of type String named text that...
Define a class named Document that contains an instance variable of type String named text that stores any textual content for the document. Create a method named toString that returns the text field and also include a method to set this value. Next, define a class for Email that is derived from Document and includes instance variables for the sender, recipient, and title of an email message. Implement appropriate set and get methods. The body of the email message should...
In c++ Design a class named Account that contains: a.An int data field named id for...
In c++ Design a class named Account that contains: a.An int data field named id for the account. b.A double data field named balancefor the account. c.A double data field named annualInterestRate that stores the current interestrate. d.A no-arg constructor that creates a default account with id 0, balance 0, andannualInterestRate 0. e.The set and get functions for id,balance, and annualInterestRate. f.A functionearnedAmount()that calculates and returns the amount of dollars earned after one year. g.A function named printAccountInfo() that print...
python Design a class named IP_address to represent IP address objects. The IP_addressclass contains the following...
python Design a class named IP_address to represent IP address objects. The IP_addressclass contains the following A number of instance variables/fields to store a table of data. You can design them by your own. A constructor that creates a table with the following: a list of data. ip address a integer to indicate the number of elements in the sum_list/freq_list/average_list A get_ip_address() method that returns the ip address For example, consider the following code fragment: ip_key = '192.168.0.24' data_list =[(0,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT