Question: #include struct HorchateRecipe { char ingredient [ 3 0 ] ; int quantity; struct HorchataRecipe * nextIngredientAddress; } ; int main ( ) {

"#include
struct HorchateRecipe
{
char ingredient[30];
int quantity;
struct HorchataRecipe *nextIngredientAddress;
};
int main()
{
struct HorchataRecipe ingredient1={Rice,6};
struct HorchataRecipe ingredient2={Sugar,1}; // # of cups
struct HorchataRecipe ingredient3={Milk,2}; // # of cups
struct HorchataRecipe ingredient4={Cinnamon,1}; // # of packets
struct HorchataRecipe *first; //create a er called *first to the first element in structure
first = &ingredient1;
ingredient1.nextIngredientAddress = &ingredient2;
/* Your assignment..if you choose to accept... is to populate
the *nextIngredientAddress for the 3 remaining ingredients and then print out all the names of the ingredients
*/ XN13
?// set ingredient2's nextIngredientAddress to ingredient 3
?// set ingredient3's nextIngredientAddress to ingredient 4
?// set ingredient4's nextIngredientAddress to NULL
/*
HINT: There's two ways to print out the values
1. er method:
printf(""%d %s
"", first->quantity, first->ingredient);
printf(""%d %s
"", first->nextIngredientAddress->quantity, first->nextIngredientAddress->ingredient);
printf(""%d %s
, first->nextIngredientAddress->nextIngredientAddress->quantity, first->nextIngredientAddress->nextIngredientAddress->ingredient);
2. Explicit Reference to each ingredient
printf(""%d %s
"", ingredient1.quantity, ingredient1. ingredient);
printf(""%d %s
"", ingredient2.quantity, ingredient2.ingredient);
*/
printf(""%s
%s
%s
%s
"",?,?,?,?);
return 0;
}"

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 Programming Questions!