#include <stdio.h>
#include <conio.h>
#include <string.h>
main() {
char d[10];
int value = 0, val1, val2;
printf("Enter Day: ");
scanf("%c", &d);
val1 = strcmp(d, "sunday");
val2 = strcmp(d, "saturday");
if (val1 == 0) {
printf("AS");
value = 2;
} else
if (val2 == 0) {
value = 1;
}
switch (value) {
case 2:
printf("So sad, you will have to work");
break;
case 1:
printf("Enjoy! its holiday");
break;
default:
printf("Print valid character");
}
}
I enter code here want to input days and to get some output using switch statement but strcmp is not working in if statement
I have to use a switch statement also
if statement not recognising value.
main() { … }has been non-standard for the whole of this millennium; it was made non-standard in C99. You should not be writing obsolete code! You should explicitly specify the return type (int), and it is best to useint main(void)when your program does not heed command-line arguments.<conio.h>AFAICS; omit the header. You should include abreak;after thedefault:case, as a protection against future enhancements. You should output a newline at the end of the variousprintf()statements — get into the habit of terminating outputs with newlines.scanf("%c",&d);. Should be%s. Voting to close as simple typo.