I want to make a program in C to take input form user who wants a specific type of drink and not anything else but the code won't work properly and directly executes if statement
#include <stdio.h>
void main()
{
char ch_a, ch_b, ch_c, ch_cond_1='y', ch_cond_2='Y';
if(ch_a == ch_cond_1 || ch_a == ch_cond_2)
{
printf("Is cold drink available?(Y/N): ");
scanf("%c", &ch_a);
if(ch_b == ch_cond_1 || ch_b == ch_cond_2)
{
printf("Is Sprite available?(Y/N): ");
scanf("%c", &ch_b);
if(ch_c == ch_cond_1||ch_c == ch_cond_2)
{
printf("Is is available in 1.5 ltr?(Y/N: ");
scanf("%c", &ch_c);
printf("Your desired product is available");
}
}
}
else
{
printf("Your desired product isn't available");
}
return 0;
}
Aucun commentaire:
Enregistrer un commentaire