fork download
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5. struct book {
  6. char name[50];
  7. float price;
  8. float discount;
  9. } book1;
  10.  
  11. printf("Enter book name : ");
  12. gets(book1.name);
  13. printf("Enter book price : ");
  14. scanf("%f", &book1.price);
  15. book1.discount = 0.1 * book1.price;
  16.  
  17. printf("\n\n\nBook : %s\n", book1.name);
  18. printf("Price : %.2f\n", book1.price);
  19. printf("Discount 10 percent : %.2f\n"
  20. "Total price : %.2f",
  21. book1.discount,
  22. book1.price - book1.discount);
  23.  
  24. return 0;
  25. }
Success #stdin #stdout 0s 5284KB
stdin
Programming in Turboc
200

Programming in turboc
200.00
20.00
180.00
stdout
Enter book name : Enter book price : 


Book : Programming in Turboc
Price : 200.00
Discount 10 percent : 20.00
Total price : 180.00