logo codesdope

error spotted for answer under Decide if/else level 3 question 4. Scanf contains a foreign input (map). Hope i am right.

   goodnesstous

#include <stdio.h>
int main()
{
  char sex;
  char marital_status;
  int age;

  printf("Enter sex, marital status and age\n");
  scanf(" %c %c %d",&map;sex,&marital_status,&age);

  if(sex == 'F' && age>=20 && age<=60)
  {
    printf("You will work in urban area.\n");
  }
  else if(sex=='M' && age>=20 && age<=40)
  {
    printf("You can work anywhere.\n");
  }
  else if(sex=='M' && age>40 && age<=60)
  {
    printf("You will work in urban area.n\n");
  }
  else
  {
    printf("Error.\n");
  }
  return 0;
}

  • Thanks
    - Amit Kumar

Answers

Share what you know
Write your answer
Close

Welcome.please sign up.

Close

Welcome.please login.