fork download
  1. #include <stdio.h>
  2. main()
  3. {
  4. char topping[24];
  5. int slices;
  6. int month, day, year;
  7. float cost;
  8.  
  9. // The first scanf will look for a floating-point variable, the cost
  10. // of a pizza
  11. // If the user doesn't enter a $ before the cost, it could cause
  12. // problems
  13. printf("How much does a pizza cost in your area?");
  14. printf("enter as $XX.XX)\n");
  15. scanf(" $%f", &cost);
  16.  
  17. // The pizza topping is a string, so your scanf doesn't need an &
  18. printf("What is your favorite one-word pizza topping?\n");
  19. scanf(" %s", topping);
  20.  
  21. printf("How many slices of %s pizza", topping);
  22. printf("can you eat in one sitting?\n");
  23. scanf(" %d", &slices);
  24.  
  25. printf("What is today's date (enter it in XX/XX/XX format).\n");
  26. scanf(" %d/%d/%d", &month, &day, &year);
  27.  
  28. printf("\n\nWhy not treat yourself to dinner on %d/%d/%d",
  29. month, day, year);
  30. printf("\nand have %d slices of %s pizza!\n", slices, topping);
  31. printf("It will only cost you $%.2f!\n\n\n", cost);
  32. return (0);
  33. }
Success #stdin #stdout 0s 2012KB
stdin
Standard input is empty
stdout
How much does a pizza cost in your area?enter as $XX.XX)
What is your favorite one-word pizza topping?
How many slices of ԙB� pizzacan you eat in one sitting?
What is today's date (enter it in XX/XX/XX format).


Why not treat yourself to dinner on -1077829774/134513545/-1077829774
and have -1077836476 slices of ԙB� pizza!
It will only cost you $0.00!