In: Computer Science
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;
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 */