Consider the following questions about structures. (a) (5 Points) Declare a stru
ID: 3590589 • Letter: C
Question
Explanation / Answer
struct Song{ // Struct for song
string title;
string artist;
int year;
enum genre{Rock, Pop, Country, Oldies};
union media{
float cost;
enum type{CD, tape};
}music;
};
int main() {
struct Song *songPtr = malloc(sizeof (struct Song));
songPtr->title="Jaded";
songPtr->artist="Aerosmith";
songPtr->year=2001;
songPtr->genre=Rock;
songPtr->music.cost=17.99;
songPtr->music.type=CD;
cout<<songPtr->title;
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.