Explore BrainMass

C Programming Help

C Programming Problem. I need help writing a program in C that meets the following criteria:
1) There are 5 products for sale at a grocery store ( I want to use cucumbers, lettuce, grapes, apples and bananas)
2) The five products are all sold by weight (pounds).
3) Customers need to be prompted to enter the price (per pound) for each of the products (cucumbers, lettuce, grapes, apples and bananas)
4) A customer has a unique request. He wants to know the maximum amount of each product that can be purchased for $10.
5) Computer & output the maximum weight of each product the customer can buy for $10.
6) Include comments within the code to explain each of the functional areas.


Solution Preview

#include <stdio.h>

int main(int argc, char **argv)
float price[5];//price array variable is declared as float to accept price of 5 vegetables
int i; //declare i as integer for looping
char vegetables[5][10] = {"Cucumber","Lettuce","Grapes","Apples","Bananas"} ;

char f,e; //f is a character for prompting user to get maximum weight, e is a character to quit
float quantity; //quantity is a float variable ...