Ff

 #include <stdio.h>


struct people {

  char name[1024];

  int age;

  char sex;

  char dob[16];

};


#define AN_MAX_PEOPLE 10


struct people an_input_person(void) {

  struct people an_res;

  printf("\nEnter details for a person:\n");

  printf("Enter name: ");

  scanf(" %[^\n]", an_res.name);

  printf("Enter age: ");

  scanf("%d", &an_res.age);

  printf("Enter sex: ");

  scanf(" %c", &an_res.sex);

  printf("Enter DOB as DD/MM/YYY: ");

  scanf("%s", &an_res.dob);

  printf("\n");

  return an_res;

}


void an_display_person(struct people an_p, int an_sl_no) {

  printf("%d\t%s\t%d\t%s\n", an_sl_no, an_p.name, an_p.age, an_p.dob);

}


int main() {

  struct people an_p[AN_MAX_PEOPLE];

  for (int an_i = 0; an_i < AN_MAX_PEOPLE; ++an_i) {

    an_p[an_i] = an_input_person();

  }

  int an_sl_no = 1;

  printf("\n\nSl.No.\tName\tAge\tDOB\n");

  for (int an_i = 0; an_i < AN_MAX_PEOPLE; ++an_i) {

    if (an_p[an_i].sex == 'F' || an_p[an_i].sex == 'f') {

      an_display_person(an_p[an_i], an_sl_no++);

    }

  }

}

Comments

Popular Posts