Final answer:
To generate a receipt for a restaurant in C, you can use the code provided. It allows the user to enter the bill amount and decide if they would like to leave a 15 percent tip or not. The program calculates the tax amount, tip amount, and total amount, and displays them.
Step-by-step explanation:
To generate a receipt for a restaurant in C, you can use the following code:
#include <stdio.h>
int main() {
 float billAmount, tipAmount, taxAmount, totalAmount;
 printf("Enter the bill amount: ");
 scanf("%f", &billAmount);
 if (billAmount < 0) {
 printf("Invalid bill amount.");
 return 0;
 }
 taxAmount = billAmount * 0.0825;
 printf("The tax amount is: $%.2f\\", taxAmount);
 printf("Would you like to leave a 15 percent tip? (1 for yes, 0 for no): ");
 int tipChoice;
 scanf("%d", &tipChoice);
 if (tipChoice == 1) {
 tipAmount = billAmount * 0.15;
 } else if (tipChoice == 0) {
 tipAmount = 0;
 } else {
 printf("Invalid tip choice.");
 return 0;
 }
 totalAmount = billAmount + taxAmount + tipAmount;
 printf("Bill amount: $%.2f\\", billAmount);
 printf("Tax amount: $%.2f\\", taxAmount);
 printf("Tip amount: $%.2f\\", tipAmount);
 printf("Total amount: $%.2f\\", totalAmount);
 return 0;
}