I want this switch statement to initialize the right value to the variable option but it is not initializing therefore not allowing the if statement to work.
#define arti 2.05
int main(void)
{
char ch;
float option = 0;
while(ch = getchar())
{
ch = toupper(ch);
switch(ch)
{
case 'A':
option = arti; //value of arti is 2.05
break;
case 'B':
option = beets;
break;
default:
printf("Enter a valid value.\n");
continue;
break;
}
if(option == arti)
{
printf("arti printed successfully!\n");
}
}
return 0;
}
The output i am getting is this:
a //input
Enter a valid value. //output
I don't know where is the problem i have made this code as short as possible to explain you the problem. Please help me with this.
Aucun commentaire:
Enregistrer un commentaire