The Question: Write a function main that prompts a user to enter the number of different items that he intends to purchase from a showroom.Your program should read for each item the quantity to purchase and the unit price then finally display total amount to be paid

anyone help me with my codes i am really stuck i am having those errors:
1.switch quantity not an integer label not within a switch statement
3.break statement not within loop or switch


float ComputeAmount(int x, int y);

int main()
    int a, totalAmount, z, k;

    printf("Enter number of different items to be purchased: ");
    scanf("%d", &a);


    return 0;
float ComputeAmount(int x, int y){

      int a, totalAmount, k, z;

      printf("Enter quantity: ");
      scanf("%d", &z);

      printf("1: k<=100");
      printf("2: k<=200");
      printf("3: k<=300");
      printf("4: k>300");

      printf("Enter amount: ");
      scanf("%d", &k);

                   case 1:{totalAmount=z*k;
                   case 2:{totalAmount=z*(k*0.05);
      return (totalAmount);


Line 33: Remove the " and the ;
On line 31 you read in the integer variable k, you don't have to place double quotes around it in the switch.

This article has been dead for over six months. Start a new discussion instead.