int xarr[5]; int next_available_location;
and the current value of next_available_location is 5, it is possible to insert one more item into the list.
Address Memory Contents Variable Allocations 2000 4040 p1 2004 3020 p2 ... ... ... 3020 1004 ... ... 4040 8040
The value stored in *p1 is 4040.
Address Memory Contents Variable Allocations 2000 2020 p1 2004 2024 p2 ... ... ... 2020 100 2024 55
*p1 = 42; p1 = p2; cout << *p1 << " " << *p2;
A. 100 55 B. 42 42 C. 42 55 D. 55 55
Address Memory Contents Variable Allocations 2000 ? p1 2004 ? p2 ... ... ... 2016 ? ... ... ... 3020 ?
Address Memory Contents Variable Allocations 2000 3020 p1 2004 2016 p2 ... ... ... 2016 2 ... ... ... 3020 2 A. p1 = new int; p2 = new int; *p1 = 2; *p2 = *p1; B. *p1 = new int; *p2 = new int; p1 = 2; p2 = 2; C. p2 = new int; p1 = new int; *p1 = 2; *p2 = 2; D. *p1 = new int; *p2 = new int; p1 = 2; p2 = p1;
int *p1, *p2; int x = 42; p1 = & x;
int *ptr1, *ptr2; ptr1 = new int; ptr2 = new int; *ptr1 = 100; ptr2 = ptr1; *ptr2 = 55; cout << *ptr1 << " " << *ptr2; A. 100 55 B. 55 100 C. 55 55 D. 100 100
struct BankRec { int acctNum; int balance; }; BankRec *bankPtr; bankPtr = new BankRec;
The field "balance" in the structure pointed at by "bankPtr" can be referenced using bankPtr->balance.
struct PersonRec { string name; int age; }; typedef PersonRec* PersonRecType; PersonRecType personPtr;
A. personPtr = new PersonRec(); B. new personPtr; C. personPtr = new (PersonRec); D. personPtr = new PersonRec;
A. personPtr.delete(); B. personPtr = delete(personPtr); C. delete personPtr(); D. delete personPtr;
struct PersonRec { string name; int age; }; typedef PersonRec* PersonRecType; PersonRecType personPtr; personPtr = new PersonRec;
A. personPtr.name = "John Smith"; B. string newName = "John Smith"; personPtr->name = newName; C. personPtr->name = "John Smith"; D. (*personPtr).name = "John Smith";
{ Script }
A. first = new Node; first->value = 55; first->next = first; B. Node* temp = new Node; first->value = 55; temp->next = first; C. Node* temp = new Node; temp->value = 55; temp->next = first->next; first = temp; D. Node* temp = new Node; temp->value = 55; temp->next = first; first = temp;
A. Node*cur=first; while(cur != NULL) { cur = cur->next; } delete cur; cur = NULL; B. Node* cur = first; while(cur->next != NULL) { cur = cur->next; } delete cur->next; cur->next = NULL; C. Node * cur = first->next; while (cur != NULL) { cur = cur->next; } delete cur; cur = NULL; D. None of the above.