I have been trying to solve the reason for my code being skipped when entering user input using scanf, however it only accepts the first two questions as answers from the user. No matter how I arrange the code, either the order of it, it still seems to skip the rest of the questions after the first 2 questions are answered. How do I solve this?
Please, instruct as much detail as possible I am a newbie.
Thank you,
Sincerely, some newbie teenager coding in C
#include <stdio.h>
int main() {
char topping[24];
int slices;
int month, day, year;
float cost;
// The first scanf will look for a floating-point variable, the cost
// of a pizza
// if the user doesn't enter a $ before the cost, it could cause
// problems
printf("What is your favorite pizza topping?\n") ;
scanf(" %s", topping) ;
printf("How much does a pizza cost in your area?");
printf(" enter as $xx.XX \n");
scanf(" $%f", &cost);
// The pizza topping is a string, so your scanf doesn't need an &
printf("How many slices of %s on the pizza", topping) ;
printf(" can you eat in one sitting?\n") ;
scanf(" %d", &slices) ;
printf("What is today's date (enter it in XX/XX/XX format). \n") ;
scanf("%d/%d/%d", &month, &day, &year);
printf("\n\nWhy not treat yourself to dinner on %d/%d/%d", month, day, year);
printf("\nand have %d slices of %s pizza!\n", slices, topping) ;
printf ("It will only cost you $%.2f! \n\n\n", cost);
}