Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- struct ingredients{
- int ingrs;
- int quantity;
- char iname[20][20];
- };
- struct recipes{
- char name[50];
- struct ingredients I;
- };
- struct cookbook{
- struct recipes R;
- };
- int main() {
- int n;
- printf("Enter number of recipes: \n");
- scanf("%d", &n);
- struct cookbook C[n];
- for(int i = 0; i < n; i++){
- printf("Enter name of recipe: \n");
- scanf("%s", C[i].R.name);
- printf("Enter number of ingredients: (From 2 to 10) \n");
- scanf("%d", &C[i].R.I.ingrs);
- for (int j = 0; j < C[i].R.I.ingrs; j++){
- printf("Enter name of ingredient: \n");
- scanf("%s", C[i].R.I.iname); //[j]
- printf("Enter quantity of ingredient: \n");
- scanf("%d", &C[j].R.I.quantity);
- }
- }
- for(int i = 0; i < n; i++){
- printf("Recipe: %s\n", C[i].R.name);
- for (int j = 0; j < C[i].R.I.ingrs; j++){
- printf("Ingredient: %s, quantity: %d \n", C[j].R.I.iname, C[j].R.I.quantity);
- }
- printf("\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement