Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

write a c++ program that does the following: vvvv Declare an integer pointer var

ID: 3910388 • Letter: W

Question

 write a c++ program that does the following: vvvv  Declare an integer pointer variable intPointer. Initialize it to point to an int variable     named someInt.        Assign the value 451 to someInt and output (cout) the variable someInt and output (cout)     the value pointed to by intPointer.        Write an assignment statement that indirectly stores 900 into the value pointed to by intPointer.        Output (cout) the value pointed to by intPointer and output (cout) the variable someInt,         2. Declare a pointer variable charArrPointer and initialize it to point to the first element    of a three-element char array named initials.          Write assignment statements to store 'A', 'E', and 'W' into the first three elements of     the array POINTED to by charArrPointer.  Do NOT store any values directly into the array named     initials.     3. Output (cout) the data in array charArrPointer and the data in array initials.  4. Copy the following code into your program above main:     struct NodeType {      int num;      NodeType* next;    };     5. Copy the following code into your program after main:     NodeType *newNode, *first, *last, *current;     6. Copy the following code into your program after the code you wrote for steps 1 - 3:     newNode = new NodeType;    newNode->num = 10;    newNode->next = NULL;            first = newNode;    last = newNode;            newNode = new NodeType;    newNode->num = 20;    newNode->next = NULL;            last->next = newNode;    last = newNode;     newNode = new NodeType;    newNode->num = 30;    newNode->next = NULL;                   last->next = newNode;    last = newNode;        5. Create a new NodeType node.  Assign the value 1 to the  num  data member.     Write the code to insert the new node at the beginning of the list.    6. Write the code to print the values of the data member num in the entire linked list.

Explanation / Answer

Hello Student!

Here goes the solution!

#include <iostream>

using namespace std;

struct NodeType {

int num;

NodeType* next;

};

int main() {

// Integer pointer

cout << "Ques 1 :";

int someInt;

int *intPointer;

someInt = 45;

intPointer = &someInt;

cout << *intPointer << endl;

// Char Arr pointer

cout << "Ques 2 :";

char *charArrPointer;

char initials[3];

char temp = 'A';

initials[0] = temp;

initials[1] = temp+4;

initials[2] = temp+22;

charArrPointer = initials;

cout << endl;

// Output the char

cout << "Ques 3 :";

cout << *charArrPointer << " " << *(charArrPointer+1) << " " << *(charArrPointer+2) << endl;

// Node

cout << "Ques 4,5,6 :";

NodeType *newNode, *first, *last, *current;

newNode = new NodeType;

newNode->num = 10;

newNode->next = NULL;

  

first = newNode;

last = newNode;

  

newNode = new NodeType;

newNode->num = 20;

newNode->next = NULL;

  

last->next = newNode;

last = newNode;

  

newNode = new NodeType;

newNode->num = 30;

newNode->next = NULL;

  

last->next = newNode;

last = newNode;

  

// To insert it in begining of the list

newNode = new NodeType;

newNode->num = 1;

newNode->next = NULL;

  

newNode->next = first;

first = newNode;

  

// To print all the values

  

newNode = first;

while (newNode != NULL) {

cout << newNode->num << " ";

newNode = newNode->next;

}

cout << endl;

return 0;

}

Output :

Ques 1 :45

Ques 2 :

Ques 3 :A E W

Ques 4,5,6 :1 10 20 30

Program ended with exit code: 0

Thank you. Feel free to ask anything. Please upvote, if you like the answer. Thank you again.