The card structure below represents a playing card with a


1.

a. Create a Card structure that holds a playing card's face and suit.
struct Card {
string face;
string suit;
};

b. Create a Student structure that holds a first name, last name, and student id.

c. Create a Product structure that holds an item name and price in dollars.

d. Create an Employee structure that holds a full name and a boss(which is are ference to this Employee type).

Note that you might have to look up self--- referencing structures to figure this one out.

2. The Card structure below represents a playing card with a face value and a suit. Using the main code given, set the cards in the deck array to be one of each kind of playing card.

The order doesn't matter.

Set the deck using only one loop.
struct Card {
string face;
string suit;
};
//In main
Card deck[52];
int numFaces = 13;
int numSuits = 4;
string faces[numFaces] = { "Ace", "Two", "Three", "Four",
"Five", "Six", "Seven", "Eight", "Nine", "Ten", "Jack",
"Queen", "King" };
string suits[numSuits] = { "Hearts", "Spades", "Diamonds",
"Clubs" };
//Fill deck here

Type aliases

3. What does a type alias do? Does it create a new data type? How do you use an alias after you create it?

4. For each of the following examples, create one type alias using the "typedef" keyword and another using the "using" keyword. The first one is done for you as an example.

a. The type "name" as a string.
typedef string name;
using name = string;

b. The type "student_id" as an unsigned integer.

c. The type "grade" as a pointer to a character.

d. Using the Card structure from the previous question in this homework, create the type "deck" as an array of 52 Cards
(Card[52]).

Pointer Concepts


5. Fill in the blanks of the following statements. You may write them in the blank space under the statements. (4 points each)

A pointer is a variable that contains as its value the _________ of another variable.
The three values you can use to set the pointer to null are__________, ___________, and___________.
c. If you don't initialize a pointer to null, you should set it to ______________________________________________.
The notations used to access values in a sequence in memory are the pointer/________ notation and the pointer/_________ notation.
The sizeof operator determines the size of a type, variable, or constant measured in units of __________.
A pointer---based string ends with a special character called the _____________.

Pointer Practice

6. What does the following code output to the console?

Be sure to format the output exactly as it would appear. There are no errors.

#include
using namespace std;
void mystery(int*, int*, size_t);
void printArray(int*, size_t);
int main() {
int numbers1[5] = {1, 2, 3, 4, 5};
int numbers2[5] = {1, 1, 1, 1, 1};
int numbers3[8] = { };
mystery(numbers2, numbers1, 5);
mystery(numbers3 + 3, numbers1, 5);
printArray(numbers1, 5);
printArray(numbers2, 5);
printArray(numbers3, 8);
}
void mystery(int *p1, int *p2, size_t length) {
for(int x = 0; x < length; x++) {
*(p1 + x) += *(p2 + x);
}
}
void printArray(int *p, size_t length) {
for(int x = 0; x < length; x++) {
cout << p[x] << " ";
}
cout << endl;
}

Solution Preview :

Prepared by a verified Expert
Basic Statistics: The card structure below represents a playing card with a
Reference No:- TGS01236882

Now Priced at $15 (50% Discount)

Recommended (90%)

Rated (4.3/5)