Anything wrong with this bit of code - TechRepublic
General discussion
November 3, 2002 at 07:14 PM
mckay_w

Anything wrong with this bit of code

by mckay_w . Updated 23 years, 5 months ago

Learning C
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’)

This discussion is locked

All Comments