How to do the option for Yes and No?
Hello. I’m new to C-programming. Can anyone help me out? I can’t find the code to solve this-
• Display a WELCOME MENU.
• Ask the user if they would like to continue. ‘Y’ to continue and ‘N’ to stop.
• As long as the choice is ‘Y’ then :
o Ask the user to enter the customer’s name.
o Ask the user to enter the weight of the groceries.
Code:
#include<stdio.h>
#include<string.h>
void main()
{
char customer_name[30] , ans;
float weight;
printf("\n***********************************************");
printf("\\n* WELCOME TO THE GROCERIES SHOP *");
printf("\n***********************************************");
printf("Would you like to continue (Y/N)?");
scanf("%c", ans);
if(ans == 'y' || ans == 'Y')
{
printf("\nEnter customer’s name: ");
gets(customer_name);
printf("\nEnter weight of groceries[KG]: ");
scanf("f" ,&weight);
}
else(ans == 'n' || ans == 'N');
break;
{
}