i have an assignment to create a program.
Mang Tomas paid a certain amount of Bushels of wine to be delivered this weekend
for his promotional party. What will the rate of each Bushel of Beer and how
much dicount will be given to them?

Number of Bushels              Discount
       1 - 3                     none
       4 - 7                     5% of each Bushel
       7 and above               7% of total amount

when i test to run the program it is ok but after i enter a value an error occur, you can see on attachment the error.

this is the program i created i hope someone can help me, Thank you :)

#include<stdio.h>
#include<conio.h>
double a;
main()
{
      printf("\n\n\n\t\tBushels of Wine Brewery Co..");
      printf("\n\n\tYou can have discounts when you order bushels of wine");
      printf("\n\n\tdepending on the amount you want.");
      printf("\n\n\t\tNumber of Bushels          Discount");
      printf("\n\t\t1 to 3                        none");
      printf("\n\t\t4 to 6                        5 percent each bushel");
      printf("\n\t\t7 and above                   7 percent of total bushels");
      printf("\n\n\tEnter desiired amount of Bushels of wine:\t");
      scanf("%lf",a);
      if(a<=3)
                    
                    printf("No discount");
      else if(a>3<7)
           
                    printf("You get 5% discount on each bushels");
      else
           {
                    printf("You get 7% discount on the total amount of the bushels");
                    }
      printf("Thank you for buying at us. Have a nice day.");
      getch();
}
scanf("%lf",a);

You're missing the address-of operator:

scanf("%lf", &a);

I already change scanf("%lf",a); to scanf("%i",a);
but same error occured

I already change scanf("%lf",a); to scanf("%i",a);

Are you reading impaired? The format specifier is correct for reading into a double, but it requires a pointer. Most of the time this means you need to pass the address of your variable. The error you're getting occurs because the value of a is being used as an address, which is invalid, and causing an access violation.

Also: if(a>3<7) is bogus. Did a warning about it show up when you compiled?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.