#include <stdio.h>
#include <string.h>
#define max 100
struct mobile
{
char mobilebrand[100];
int qty;
int price;
};
int main()
{
int choice, n;
char brand[max];
struct mobile m1[max];
printf("Menu\n");
printf("1. Sorting\n2. Searching\n3.Exit\n");
while (1)
{
printf("Enter your choice: ");
scanf("%d", &choice);
switch (choice)
{
case 1:
{
printf("Enter the number of mobiles brands you want to sort: ");
scanf("%d",&n);
getchar();
for (int i = 0; i < n; i++)
{
printf("Mobile brand: ");
scanf("%s", &m1[i].mobilebrand);
printf("Quantity: ");
scanf("%d", &m1[i].qty);
printf("Price(Rs): ");
scanf("%d", &m1[i].price);
printf("\n");
}
break;
}
case 2:
{
printf("Enter mobile brand to search: ");
scanf("%s", &brand); //check here if erro
if(strcmp(brand,m1[0].mobilebrand)==0)
{
printf("Stock in hand:%d\n", m1[0].qty);
printf("Total Cost of Inventory (Rs): %d\n", m1[0].qty * m1[0].price);
}
else if(strcmp(brand,m1[1].mobilebrand)==0)
{
printf("Stock in hand:%d\n", m1[1].qty);
printf("Total Cost of Inventory (Rs): %d\n", m1[1].qty * m1[1].price);
}
break;
}
case 3:
goto end;
default:
break;
}
}
end:
return 0;
}