Question
1. Given the following struct: struct bankCD { double amount; double interestRate; int years; }; a. What is the name of the struct? b. What
1. Given the following struct:
struct bankCD
{
double amount;
double interestRate;
int years;
};
a. What is the name of the struct?
b. What are the members of the struct?
c. Has any memory been allocated?
d. Declare two variables of type bankCD, and give all members values.
2. What does the following code do?
bankCD deposits[10];
int i;
for (i = 0; i < 10; i++)
{
deposits[i].amount = 0;
deposits[i].interestRate = .05;
deposits[i].years = 1;
}
3. Suppose the following struct:
const int ARRAY_SIZE = 100;
struct listType
{
string listElem[ARRAY_SIZE];
int listLength;
};
struct sectionInfo
{
listType studentList;
string sectionNum;
};
What is printed out by the following code?
sectionInfo CSC211;
CSC211.studentList.listElem[0] = "Joe";
CSC211.studentList.listElem[1] = "Mel";
CSC211.studentList.listElem[2] = "Sal";
CSC211.sectionNum = "9056";
CSC211.studentList.listLength = 3;
for ( int i = 0; i < CSC211.studentList.listLength; i++)
cout << "Student # " << i << " of class " << CSC211.sectionNum << ":"
<< CSC211.studentList.listElem[i] << endl;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started