because it ends my program as soon as i clicked "N". only the else statement has the problem, the if is running good. thank you for your answers, it really helps me alot.
#include <stdio.h>
int main()
{
char name[20];
char address[50];
char items[60];
char answer;
char pay[50];
printf("Enter your name: ");
fgets(name, 20, stdin);
printf("Your name is %s", name);
printf("Enter your specific address: ");
fgets(address, 50, stdin);
printf("Your address is %s", address);
printf("Enter your items that you want to buy: ");
fgets(items, 60, stdin);
printf("Your item/s is/are %s", items);
printf("Would you like to pay it after delivery? Enter Y or N: ");
scanf (" %c", &answer);
printf("Your answer is %c\n", answer);
if (answer == 'Y')
{
printf("Success!");
} else
{
printf("How would you like to be paid?");
printf("\nPlease specify how would you like to be paid: ");
fgets(pay, 50, stdin);
printf("%s", pay);
}
printf("Thank you!");
return 0;
}