jeudi 21 septembre 2017

C code not coming out right?

So here's the code that I'm entering in for this specific section. When I try to run it for the section where I answer "yes" "yes" and "no" it prints out

"Call them (and be prepared to spend at least 10 minutes on the phone Do nothing (let them call you )Are you in their will?"

Can someone please explain to me why it's doing that? Thanks.

  if (strcmp(userAnswer, "other")==0) {
printf("Is it one of your grandparents?\n");
scanf("%s", userAnswer);
if (strcmp(userAnswer, "yes")==0) {
  printf("Do they like you?\n");
  scanf("%s", userAnswer);
  if (strcmp(userAnswer, "yes")==0) {
    printf("But do they like everyone?\n");
    scanf("%s", userAnswer);
    if (strcmp(userAnswer, "yes")==0) {
      printf("Send a quick text about your day\n");
    }
    if (strcmp(userAnswer, "no")==0) {
      printf("Call them (and be prepared to spend at least 10 minutes on the phone\n");
    }
  }
if (strcmp(userAnswer,"no")==0) {
    printf("Do nothing (let them call you\n)");
  }
}
if (strcmp(userAnswer,"no")==0) {
  printf("Are you in their will?\n");
  scanf("%s", userAnswer);
    if (strcmp(userAnswer,"no")==0) {
      printf("Do nothing(let them call you)");
    }
    if (strcmp(userAnswer, "yes")==0) {
      printf("Call them (and be prepared to spend at least 10 minutes on the phone)\n");
    }
}

}

Aucun commentaire:

Enregistrer un commentaire