CSE 240 COMPLETE QUESTIONS AND
SOLUTIONS TESTED ANSWERS
◉ Given the following:
int num1 = 5; //addressed at 1877112
int num2 = 15; //addressed at 1877300
int num3 = 20; //addressed at 1877192
double d1 = 1.05; //addressed at 1374376
double d2 = 2.25; //addressed at 1374360
double d3 = 3.14; //addressed at 1374344
After these statements:
int* ptr1 = &num3
ptr1 = ptr1 + 5;
What will be the address contained in ptr1?
Answer: 1877212
◉ Which of the following statements will allow me to give the
value of 10 to the memory int* myPtr points to?
Answer: *myPtr = 10;
,◉ int num1 = 5; //addressed at 1767612
int num2 = 10; //addressed at 1767600
int num3 = 15; //addressed at 1767588
char ch1 = 'a'; //addressed at 3734375
char ch2 = 'b'; //addressed at 3734363
char ch3 = 'c'; //addressed at 3734351
char* chPtr = &ch3;
int* iPtr = &num3;
*iPtr = num3 *(times) 8;
'*chPtr' = '*iPtr;'
What will the following statement output?
,cout << ch3;
Answer: 'x'
◉ (True or False) Multiple pointers can reference the same
objects.
Answer: True
◉ C/C++ has 2 pointer operators, which operator represents the
name of the address? (Commonly refer as l-value.)
Answer: Asterisk (*)
◉ Given this snippet of code, what is the value of x after executing
the last statement?
int x = 10, *y;
y = &x;
y = y + 1;
*y = 100;
Answer: 10
, ◉ Given this snippet of code, what is the value of x after executing
the last statement?
int x = 10, *y;
y = &x;
*y = 100;
Answer: 100
◉ Given this snippet of code, what is the value of z after executing
the last statement?
int x = 10, *y, **z;
z = &y;
y = &x;
*y = 100;
Answer: None of the above (Memory Address)
◉ A pointer variable can take the address of a memory location as
its value. Read the given program.
SOLUTIONS TESTED ANSWERS
◉ Given the following:
int num1 = 5; //addressed at 1877112
int num2 = 15; //addressed at 1877300
int num3 = 20; //addressed at 1877192
double d1 = 1.05; //addressed at 1374376
double d2 = 2.25; //addressed at 1374360
double d3 = 3.14; //addressed at 1374344
After these statements:
int* ptr1 = &num3
ptr1 = ptr1 + 5;
What will be the address contained in ptr1?
Answer: 1877212
◉ Which of the following statements will allow me to give the
value of 10 to the memory int* myPtr points to?
Answer: *myPtr = 10;
,◉ int num1 = 5; //addressed at 1767612
int num2 = 10; //addressed at 1767600
int num3 = 15; //addressed at 1767588
char ch1 = 'a'; //addressed at 3734375
char ch2 = 'b'; //addressed at 3734363
char ch3 = 'c'; //addressed at 3734351
char* chPtr = &ch3;
int* iPtr = &num3;
*iPtr = num3 *(times) 8;
'*chPtr' = '*iPtr;'
What will the following statement output?
,cout << ch3;
Answer: 'x'
◉ (True or False) Multiple pointers can reference the same
objects.
Answer: True
◉ C/C++ has 2 pointer operators, which operator represents the
name of the address? (Commonly refer as l-value.)
Answer: Asterisk (*)
◉ Given this snippet of code, what is the value of x after executing
the last statement?
int x = 10, *y;
y = &x;
y = y + 1;
*y = 100;
Answer: 10
, ◉ Given this snippet of code, what is the value of x after executing
the last statement?
int x = 10, *y;
y = &x;
*y = 100;
Answer: 100
◉ Given this snippet of code, what is the value of z after executing
the last statement?
int x = 10, *y, **z;
z = &y;
y = &x;
*y = 100;
Answer: None of the above (Memory Address)
◉ A pointer variable can take the address of a memory location as
its value. Read the given program.