C Programming Data Structure City String compare | Vaccination Question

Write a Modular C Programming code for Finding the number and details of the people who took Vaccinations in different locations.

Display:

  1. The details of People of Hubbali who are above 17 & took once vaccination
  2. The details of People of Dehli who are above 17 & took Twice vaccination

Read the number of students, read their information, and display the details of the students:

CODE:

#include<stdio.h>
struct people
{
char name[30];
int age;
char gender[10];
char place[30];
int times;
};
struct people p[100];
void read(struct people p[100], int n);
void display(struct people p[100], int n);
void finding(struct people p[100], int n);
int n, i;
main()
{
printf("Enter the no. of People you want to give info: ");
scanf("%d",&n);
read(p,n);
display(p,n);
finding(p,n);

}
void read(struct people p[100], int n)
{
    int i;
    printf("\nEnter the details of Peoples: \n");
for(i=0;i<n;i++)
{
printf("\nEnter the Name: ");
scanf("%s",&p[i].name);
printf("Enter the Age: ");
scanf("%d",&p[i].age);
printf("Enter the Gender (F or M): ");
scanf("%s",&p[i].gender);
printf("Enter the place:");
scanf("%s",&p[i].place);
printf("Enter the no_Of_times vaccination took:");
scanf("%d",&p[i].times);
printf("\n+++++++++++++++++++++++++++++++++++++++++++++++++\n");
}
}

void display(struct people p[100], int n)
{
    int i;
    printf("\nThe details of Peoples are: \n");
for(i=0;i<n;i++)
{
printf("\nName: %s",p[i].name);
printf("\nAge: %d",p[i].age);
printf("\nGender: %s",p[i].gender);
printf("\nPlace: %s",p[i].place);
printf("\nno_Of_times: %d",p[i].times);
printf("\n\n+++++++++++++++++++++++++++++++++++++++++++++++++\n");
}
}

void finding(struct people p[100], int n)
{
    int i;
    for(i=0;i<n;i++) { if((((strcmp(p[i].place,"hubballi"))==0) && p[i].times==1) && p[i].age>17)
        {
            printf("\nThe details of People of Hubbali who are above 17 & took once vaccination\n");
            printf("\nName: %s",p[i].name);
            printf("\nAge: %d",p[i].age);
            printf("\nGender: %s",p[i].gender);
            printf("\nPlace: %s",p[i].place);
            printf("\nno_Of_times: %d",p[i].times);
            printf("\n\n+++++++++++++++++++++++++++++++++++++++++++++++++\n");
        }
    }
   for(i=0;i<n;i++) { if((((strcmp(p[i].place,"dehli"))==0) && p[i].times==2)&& p[i].age>17)
        {
            printf("\nThe details of People of Dehli who are above 17 & took Twice vaccination\n");
            printf("\nName: %s",p[i].name);
printf("\nAge: %d",p[i].age);
printf("\nGender: %s",p[i].gender);
printf("\nPlace: %s",p[i].place);
printf("\nno_Of_times: %f",p[i].times);
printf("\n\n+++++++++++++++++++++++++++++++++++++++++++++++++\n");
        }
    }
}

OUTPUT

Enter the no. of People you want to give info: 5

Enter the details of Peoples:

Enter the Name: Harish
Enter the Age: 19
Enter the Gender (F or M): M
Enter the place:hubballi
Enter the no_Of_times vaccination took:1

+++++++++++++++++++++++++++++++++++++++++++++++++

Enter the Name: Ganesh
Enter the Age: 20
Enter the Gender (F or M): M
Enter the place:hubballi
Enter the no_Of_times vaccination took:2

+++++++++++++++++++++++++++++++++++++++++++++++++

Enter the Name: Raj
Enter the Age: 16
Enter the Gender (F or M): M
Enter the place:Mumbai
Enter the no_Of_times vaccination took:2

+++++++++++++++++++++++++++++++++++++++++++++++++

Enter the Name: Sup
Enter the Age: 20
Enter the Gender (F or M): F
Enter the place:delhi
Enter the no_Of_times vaccination took:2

+++++++++++++++++++++++++++++++++++++++++++++++++

Enter the Name: Rum
Enter the Age: 23
Enter the Gender (F or M): F
Enter the place:delhi
Enter the no_Of_times vaccination took:2

+++++++++++++++++++++++++++++++++++++++++++++++++

The details of Peoples are:

Name: Harish
Age: 19
Gender: M
Place: hubballi
no_Of_times: 1

+++++++++++++++++++++++++++++++++++++++++++++++++

Name: Ganesh
Age: 20
Gender: M
Place: hubballi
no_Of_times: 2

+++++++++++++++++++++++++++++++++++++++++++++++++

Name: Raj
Age: 16
Gender: M
Place: Mumbai
no_Of_times: 2

+++++++++++++++++++++++++++++++++++++++++++++++++

Name: Sup
Age: 20
Gender: F
Place: delhi
no_Of_times: 2

+++++++++++++++++++++++++++++++++++++++++++++++++

Name: Rum
Age: 23
Gender: F
Place: delhi
no_Of_times: 2

+++++++++++++++++++++++++++++++++++++++++++++++++

The details of People of Hubbali who are above 17 & took once vaccination

Name: Harish
Age: 19
Gender: M
Place: hubballi
no_Of_times: 1

+++++++++++++++++++++++++++++++++++++++++++++++++

Process returned 0 (0x0)   execution time : 70.414 s
Press any key to continue.

© Credits

Jatin Kalal (1)
'H' div
Department of Electronics and Communication


(  ) — Number of Contributions!

Please find some more codes of 1D Arrays, 2D Arrays, Strings, Pointers, Data Structures, Files, Linked lists, and MISC on the below page:

Top 100+ C Programming codes – KLE Technological University

 

 







2 thoughts on “C Programming Data Structure City String compare | Vaccination Question”

  1. Bro this page is wrong!!!
    whenever I try to open the drinks comparing question it opens vaccination question
    Please edit this by this question by – Details of Drinks comparing type | least price & Display |

    Reply

Leave a Comment

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

Welcome to FactsPrime

Sorry, We have detected that you have activated Ad-Blocker. Please Consider supporting us by disabling your Ad Blocker, It helps us in maintaining this website. To View the content, Please disable adblocker and refresh the page.

Thank You !!!