When I run the program no matter what I enter for shape
, the final else statement is executed.
#include <stdio.h>
int main(void)
{
char shape = 'a';
printf("What shape do you want?\nEnter 's' for a Square, 'b' for a Box, 't' for a Triangle\n");
while (shape != 's' && shape != 'b' && shape != 't')
{
scanf_s(" %c", &shape);
if (shape == 's')
{
printf("You entered %c", shape);
}
else if (shape == 'b')
{
printf("You entered %c", shape);
}
else if (shape == 't')
{
printf("you entered %c", shape);
}
else
{
printf("Please enter 's' 'b' or 't'");
}
}
return 0;
}