Well, give me a C lesson. Why does scanf's 2nd parameter start with an ampersand in two invocations but not the first? How do you know what you get in GST? What happens in the rest of the if nest? I suggest displaying GST together with price and type: you may just find that the results make sense.
Two equals for compare. One assigns. And you can't nest compares like that.
if (Type == 'a' || Type == 'g' || Type == 'o')
if (Type == 's')
Maintain the float. GST = Price / 10.0;
You have no error checking in place. This will crash if the user doesn't enter numbers for the numeric data. Or try to read it as hex or something equally odd, like convert it to the decimal equivalent. Don't just assign user input to a variable without checking what kind of data it is.
If you're asking for technical help, please be sure to include all your system info, including operating system, model number, and any other specifics related to the problem. Also please exercise your best judgment when posting in the forums--revealing personal information such as your e-mail address, telephone number, and address is not recommended.
Anything wrong with this bit of code
anything wrong with this code
no matter what i enter, the GST is set at 10%
char Description[100];
float Price;
char Type;
float GST;
printf("Enter Description: ");
scanf(" %s", Description);
printf("Enter Price: $");
scanf("%f", &Price);
printf("Enter Type: ");
scanf(" %c", &Type);
if (Type = 'a' || 'g' || 'o')
{
GST = Price / 10;
}
else
{
if (Type = 's')