I have been struggling to get my if statement in my function to evaluate correctly. I am attempting to get the if statement to evaluate as true only if the variable is equal to 'Y' or 'y'. I am new to messing with char variables, so my suspicion is I am either storing chars into the variable incorrectly, or evaluating the expression in a way that is always true.
The code I wrote is the following:
#include <stdio.h>
// fuctions
int Greeting(void);
// variables
int return_status;
int main(void)
{
return_status = Greeting();
printf("Return status is %d \n", return_status);
return 0;
}
int Greeting(void)
{
char status;
printf("Welcome to the program. Would you like to continue?(Y/N)\n");
scanf(" %c", &status);
if (status == 'Y' || 'y') // Problem is probably here
{
printf("You have said %c.\n", status);
return 0;
}
else
{
return 1;
}
}