Q:

C programming-3 testing condition in if statements

#include <stdio.h>
#include <stdlib.h>

int main()
{
   float marks;
   char sports;
   char dance[10];

   printf("Enter your marks:\n");
   scanf(" %f",&marks);

   printf("Do you play sports?? <y/n>\n");
   scanf(" %c",&sports);

   printf("Do you dance?? <yes/no>\n");
   scanf(" %s",dance);

   if((marks >=70) && (sports == 'y') &&(dance == "yes"))
  {
    printf("You are a Good Student\n");
} else{
    printf("You are a Average student\n");
}

return 0;

}

In any scenario am not getting output as -you are a good student
am getting output if i make dance as char but i want it to solve using string.
can anyone tell me whats wrong in this code.

A:

When you do dance == "yes" you are comparing two pointers (the pointer to the first element in the array dance, and the pointer to the first letter in "yes"). And those two pointers will never be the same.
To compare string you need to use the strcmp function:
strcmp(dance, "yes") == 0

