fix my codes!!! #include #include int main() { char name [10][100]; int fc = 0, current=0,addvegetables,Name,vegetables,remark; printf(" \n Welcome to my farm !!!!!!!!! \n"); int choice, i=0; int quantity; do{ printf("------------------------------------------\n\n"); printf("1. press to ADD vegetables\n"); printf("2. PRESS TO UPDATE vegetables \n"); printf("3. PRESS TO DISPLAY vegetables \n"); printf("4. Exit \n"); printf("------------------------------------------\n\n"); printf("Enter your choice:"); scanf("%d",&choice); switch(choice){ case 1: printf("\nAdd vegetables: "); scanf(" %s",& addvegetables); printf("Quantity: "); scanf("%d",&quantity); fc++; break; case 2: printf("\nSearch vegetables: "); scanf(" %s\n",&Name); for(i=0; i
please fix my codes!!!
#include <stdio.h>
#include<string.h>
int main()
{
char name [10][100];
int fc = 0, current=0,addvegetables,Name,vegetables,remark;
printf(" \n Welcome to my farm !!!!!!!!! \n");
int choice, i=0;
int quantity;
do{
printf("------------------------------------------\n\n");
printf("1. press to ADD vegetables\n");
printf("2. PRESS TO UPDATE vegetables \n");
printf("3. PRESS TO DISPLAY vegetables \n");
printf("4. Exit \n");
printf("------------------------------------------\n\n");
printf("Enter your choice:");
scanf("%d",&choice);
switch(choice){
case 1:
printf("\nAdd vegetables: ");
scanf(" %s",& addvegetables);
printf("Quantity: ");
scanf("%d",&quantity);
fc++;
break;
case 2:
printf("\nSearch vegetables: ");
scanf(" %s\n",&Name);
for(i=0; i<fc ; i++){
char Name[100];
if (strcmp(vegetables, Name) == 0){
printf("Current Quantity: %d",current);
printf("\nEnter Quantity: ");
scanf("%d",&quantity);
}
}
break;
case 3:
printf("\n\nVegatables\t Quantity\t Remarks \n ");
for(i=0; i<fc ; i++){
printf("%d %s \t%d ",(i+1),Name,quantity,remark);
if(quantity < 10){
printf("\t warning \n");
}else{
printf("\t ok \n");
}
}
break;
case 4:
default :
printf(" work hard play hard \n");
break;
}
}while(choice != 4);
}
sample output :
1. press Add vegetables
2. press Update vegetables
3. press Display vegetables
4. Exit
Choice: 1
Add vegetables: lettuce
Quantity: 40
1. press Add vegetables
2. press Update vegetables
3. press Display vegetables
4. Exit
Choice: 1
Add fruit: carrot
Quantity: 10
1. press Add vegetables
2. press Update vegetables
3. press Display vegetables
4. Exit
Choice: 3
vegetables Quantity Remarks
1. lettuce 40 ok
2. carrot 10 ok
1. press Add vegetables
2. press Update vegetables
3. press Display vegetables
4. Exit
Choice: 2
Search vegetables: lettuce
Current quantity: 40
Enter Quantity: 35
1. Add vegetables
2. Update vegetables
3. Display vegetables
4. Exit
Choice: 3
vegetables Quantity Remark
1. lettuce 5 bad
2. carrot 10 ok
Step by step
Solved in 3 steps with 2 images