Question: Write a c++ program that performs the following steps [using pointers]: 1. Creates dynamically two variables of type int, a variable of type char, and

Write a c++ program that performs the following steps [using pointers]:

1. Creates dynamically two variables of type int, a variable of type char, and a variable of type Bag of integers. <- not sure if that is a typo or... 2. Assign to the variable the values 30, 50, 'K', and 100, respectively. 3. Add the value of the variables of type int and save the result in the first variable. 4. Copy the value of the first int variable into the second variable. 5. Finally print all the variables you have created.

I am uncertian how to perform #4. The code that I have so far is included below.

#include

using namespace std;

int main() {

int bag;

char C;

int *int1p;

int *int2p;

int *bagOfIntegersp; // there is no data type of Bags..?

char *Cp;

int1p = new int;

int2p = new int;

bagOfIntegersp = &bag;

Cp = &C;

*int1p = 30;

*int2p = 50;

*bagOfIntegersp = 100;

*Cp = 'K';

*int1p = *int1p + *int2p + *bagOfIntegersp;

cout << "The Added Integers: " << *int1p << endl;

cout << "Potassiums Elemental Symbol Is: " << *Cp << endl;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!