Question #63199

4. Write a menu driven program:
a. to read details of ‘n’ products
b. search product by ID and display, if found
c. search products by category and display all, if found
d. display products whose price is greater than Rs.500

Expert's answer

#include <stdio.h>
int main(int argc, char *argv[])
{
char choise;
int n = 0;
do {
puts("read details about n products (type 1) \t search product by
id (type 2)\t"
" search product by category (type 3) \t "
"display products whose price is greater than Rs.500 (type
4) \t"
"Quit (type q or Q)");
scanf("%c", &choise);
if (choise == '1')
{
puts("Enter n: ");
scanf("%d", &n);
for(int i = 0; i<n; i++){
//read details about n products
}
}
else
if (choise == '2')
{
//search product by id and display, if found
}
else
if (choise == '3')
{
// search products by category and display all, if
found
}
else
if (choise == '4')
{
//display products whose price is greater
than Rs.500
}
else
if (choise == 'Q' || choise == 'q')
{
puts("Bye!"); //exit message
break;
}
} while (1);
return 0;
}
https://www.AssignmentExpert.com</stdio.h>

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS