• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 2 out of 11 pages
Exam (elaborations)

C++ Chapters.

Document preview thumbnail
Preview 2 out of 11 pages

Exam of 11 pages for the course C++ Chapters at C++ Chapters (C++ Chapters)

Content preview

C++ Chapters GRADE A QUESTION AND
ANSWERS
&diff - (correct answer)Assume the variable diff has already been declared. Write an
expression whose value is the address of diff .



int *ip; - (correct answer)Declare a variable ip that can be assigned the address of an int
variable. In other words, declare ip to be of type "pointer to int ".



char *cp; - (correct answer)Declare a variable cp that can be assigned the address of an
char variable. In other words, declare cp to be of type "pointer to char ".



double *dp; - (correct answer)Declare a variable dp that can be assigned the address of
a double variable. In other words, declare dp to be of type "pointer to double ".



counterPointer = &counter; - (correct answer)Assume that an int variable counter has
already been declared. Assume further a variable counterPointer of type "pointer to int "
has also already been declared. Write a statement that makes counterPointer "point" to
counter .



diffPointer = &diff; - (correct answer)Assume that an int variable diff has already been
declared. Assume further a variable diffPointer of type "pointer to int " has also already
been declared. Write a statement that assigns the address of diff to diffPointer .


*strikeCounter * 4 - (correct answer)Assume that strikeCounter has already been
declared to be a "pointer to int ". Assume further that strikeCounter has been initialized -
- its value is the address of some int variable.


Write an expression whose value is four (4) times the value of the variable that
strikeCounter is pointing to.

, *strikeCounter = 27; - (correct answer)Assume that strikeCounter has already been
declared to be a "pointer to int ". Assume further that strikeCounter has been initialized -
- its value is the address of some int variable.



Write a statement that assigns the value 27 to the variable that strikeCounter is pointing
to.



*strikeCounter += 22; - (correct answer)Assume that strikeCounter has already been
declared to be a "pointer to int ". Assume further that strikeCounter has been initialized -
- its value is the address of some int variable.



Write a statement that adds 22 to the value of the variable that strikeCounter is pointing
to.



*ip3 = *ip1 + *ip2; - (correct answer)Assume that ip1 , ip2 , and ip3 have already been
declared to be of type "pointer to int ". Assume further that each of these pointer
variables have been initialized -- each points to some int variable.



Write a statement that computes the sum of the variables that ip1 and ip2 point to, and
assigns that value (the sum) to the variable that ip3 points to.



int *temp;
temp = xp;
xp = yp;

yp = temp; - (correct answer)The variables xp and yp have both been declared as
pointers to integers, and have been assigned values (i.e., they are each pointing to an
integer value). Write the code to exchange the values of these two variables (so that
after the swap xp points to what yp originally pointed to and vice-versa-- in other words,
in this exercise, you are swapping the pointers). Declare any necessary variables.



int x = 0;

Document information

Uploaded on
October 26, 2024
Number of pages
11
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers
$10.49

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
douglasmugwe82
5.0
(1)
Sold
2
Followers
0
Items
4215
Last sold
1 year ago



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions