printf("\n\n");
printf("*****************************************************\n");
printf("** Find Disclosed amount of your shopping bill **\n");
printf("*****************************************************\n");
printf("\nPlease enter the item name: ");
scanf("%s", &itemname);
printf("\nPlease enter the price: ");
scanf("%f", &price);
printf("\nPlease enter the discount %%: ");
scanf("%f", &discount);
printf("\nWould you like to add any more items? Y/N: ");
scanf("%s", &yn);
if(yn='y')
{
printf("\nPlease enter the item name: ");
scanf("%s", &itemname2);
printf("\nPlease enter the price: ");
scanf("%f", &price2);
total=price+price2;
discounted=total*(discount/100);
printf("\nYour total price is: %.0f\n Press ENTER to continue", discounted);
getch();
break;
}
else
discounted=price*(discount/100);
printf("\nYour total price is: %.0f\nPress ENTER to continue", discounted);
if(yn='y')
{
printf("\nPlease enter the item name: ");
scanf("%s", &itemname2);
printf("\nPlease enter the price: ");
scanf("%f", &price2);
total=price+price2;
discounted=total*(discount/100);
printf("\nYour total price is: %.0f\n Press ENTER to continue", discounted);
getch();
break;
}
else
discounted=price*(discount/100);
printf("\nYour total price is: %.0f\nPress ENTER to continue", discounted);
On line 1, it needs to be if(yn == 'y'), not if(yn='y')
== is comparing the two, used for boolean "stuff", while = is declaring yn to equal 'y'
also
1 2 3 4
else
discounted=price*(discount/100);
printf("\nYour total price is: %.0f\nPress ENTER to continue", discounted);
needs to be
1 2 3 4 5 6
else
{
discounted=price*(discount/100);
printf("\nYour total price is: %.0f\nPress ENTER to continue", discounted);
}
take note of the curly brackets, you need them a lot.