0
 #include <stdio.h>
    
    int main()
    {
        char name[15];
        int x;
        char vip[5];
        printf("enter the name of the visitor\n");
        scanf("%s", &name);
        printf("enter the age of the person\n");
        scanf("%d", &x);
        printf("do the person have vip pass\n");
        scanf("%s", &vip);
        if (x >= 18 && x < 75)
        {
            printf("%s are welcomed to the mueseum\n", name);
        }
        else if (vip == "yes")
        {
            printf("you can enter");
        }
        else
        {
            printf("sorry %s  are not allowed to enter\n", name);
        }
        return 0;
    }

here whenever i run programme my else if statement where i want vip string to work is not getting initiated

  • [How do I properly compare strings in C?](https://stackoverflow.com/questions/8004237/how-do-i-properly-compare-strings-in-c) – WhozCraig Jun 04 '21 at 11:42
  • Note that, in addition to issues comparing strings, there are problems with the structure of the logic here. There are multiple reasons why a person might not be allowed to enter, and the decision is probably best made by a separate function, that either returns a `bool` or a value that summarizes why the person is / is not being admitted. – Tim Randall Jun 04 '21 at 13:59

0 Answers0