0% found this document useful (0 votes)
257 views6 pages

Mini Project

mmm

Uploaded by

Hrithick M
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
257 views6 pages

Mini Project

mmm

Uploaded by

Hrithick M
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

EXP NO: 15 MINI PROJECT: RECIPE MANAGEMENT SYSTEM

AIM:
TO CREATE A FLEXIBLE RECIPE MANAGEMENT SYSTEM USING C
PROGRAMMING LANGUAGE.

PROGRAM:
include <stdio.h>
#include <stdlib.h>

struct Dish {
char name[50];
char ingredients[200];
char instructions[500];
};
void create(struct Dish *recipes, int *numRecipes) {
printf("Enter recipe name: ");
scanf("%s", recipes[*numRecipes].name);
printf("Enter ingredients : ");
scanf(" %[^\n]s", recipes[*numRecipes].ingredients);
printf("Enter cooking instructions: ");
scanf(" %[^\n]s", recipes[*numRecipes].instructions);
(*numRecipes)++;
printf("Recipe created successfully.\n");
}
void modify(struct Dish *recipes, int numRecipes) {
int index;
printf("Enter the index of the recipe to modify (0 to %d): ", numRecipes - 1);
scanf("%d", &index);
if (index >= 0 && index < numRecipes) {
printf("Enter new recipe name: ");
scanf("%s", recipes[index].name);
printf("Enter new ingredients: ");
scanf(" %[^\n]s", recipes[index].ingredients);
printf("Enter new cooking instructions: ");
scanf(" %[^\n]s", recipes[index].instructions);
printf("Recipe modified successfully.\n");
} else {
printf("Invalid recipe index.\n");
}
}
void delete(struct Dish *recipes, int *numRecipes) {
int index;
printf("Enter the index of the recipe to delete (0 to %d): ", *numRecipes - 1);
scanf("%d", &index);
if (index >= 0 && index < *numRecipes) {
for (int i = index; i < *numRecipes - 1; i++) {
recipes[i] = recipes[i + 1];
}
(*numRecipes)--;
printf("Recipe deleted successfully.\n");
} else {
printf("Invalid recipe index.\n");
}
}
void display(struct Dish *recipes, int numRecipes) {
if (numRecipes == 0) {
printf("No recipes available.\n");
} else {
for (int i = 0; i < numRecipes; i++) {
printf("%d. Name: %s\n Ingredients: %s\n Instructions: %s\n", i,
recipes[i].name, recipes[i].ingredients, recipes[i].instructions);
}
}
}
int main() {
struct Dish recipes[50];
int numRecipes = 0;

int choice;
do {
printf("\nRecipe Management System\n");
printf("1. Create Recipe\n");
printf("2. Modify Recipe\n");
printf("3. Delete Recipe\n");
printf("4. Display Recipes\n");
printf("5. Exit\n");
printf("Enter your choice: ");
scanf("%d", &choice);

switch (choice) {
case 1:
create(recipes, &numRecipes);
break;
case 2:
modify(recipes, numRecipes);
break;
case 3:
delete(recipes, &numRecipes);
break;
case 4:
display(recipes, numRecipes);
break;
case 5:
printf("Exiting...\n");
break;
default:
printf("Invalid choice. Please enter a number between 1 and 5.\n");
}
} while (choice != 5);
return 0; }
RESULT:
THE RECIPE MANAGEMENT SYSTEM USING C PROGRAMMING IS
CREATED AND EXECUTED SUCCESFULL BY USING C COMPILER.

You might also like