can you type an introduction and conclusion and explanation for the following code (word only ) type a lot, please
can you type an introduction and conclusion and explanation for the following code (word only ) type a lot, please
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// Function Declarations
void create_inventory();
void update_vacc_qty();
int search_vaccine();
void display_vaccine();
// Main Function starts here
int main()
{
create_inventory();
display_vaccine();
search_vaccine();
//update_vacc_qty();
return 0;
}
//Function to Create Vaccine.txt as per the given table
void create_inventory()
{
int option = 1;
// variables to collect data as per table given
char vaccinename[15];
char vaccinecode[2];
char country[15];
int dosage;
float populaion;
//File definition
FILE* infile;
infile = fopen("Vaccine.txt","w"); // file opening for writing
if (infile == NULL) // Checking for the file creation
{
printf("Vaccine.txt file unfamiliar\n");
}
//Accepting data from user from keyboard till user enters 0 to close
while (option != 0)
{
printf("Enter Vaccine Name : ");
scanf("%s", vaccinename);
printf("Enter Vaccine Code : ");
scanf("%s", vaccinecode);
printf("Enter Counry Name : ");
scanf("%s", country);
printf("Enter Dosage Required : ");
scanf("%d", &dosage);
printf("Enter Population Covered : ");
scanf("%f", &populaion);
//writing to the file using fprintf command
fprintf(infile, "%s %s %s %d %3.2f\n",vaccinename, vaccinecode, country, dosage, populaion);
printf("\n press 1 to pursue and 0 to exit : ");
scanf("%d", &option);
if (option == 0)
fclose(infile); // closing the file when user wants to exit
}
}
//Function to display the file contents in a formatted way
void display_vaccine()
{
// variables to collect data as per table given
char vaccinename[15];
char vaccinecode[2];
char country[15];
int dosage;
float populaion;
FILE* infile;
infile = fopen("Vaccine.txt", "r"); // file opening for reading
if (infile == NULL) //checking for file exists or not
{
printf("Vaccine.txt file unfamiliar\n");
}
//printing the header line
printf("%15s\t%2s\t%15s\t%6s\t%10s\n", "Vaccine Name", "Vaccine Code", "Country", "Dosage", "Population");
// Reading the file
while (fscanf(infile, "%s %s %s %d %f\n", vaccinename, vaccinecode, country, &dosage, &populaion) != EOF)
{
//printing the read data in a formatted way
printf("%15s\t%13s\t%15s\t%d\t%3.2f\n", vaccinename, vaccinecode, country, dosage, populaion);
}
fclose(infile); // closing the file
}
int search_vaccine()
{
// variables to collect data as per table given
char vaccinename[15];
char vaccinecode[2];
char country[15];
int dosage;
float populaion;
FILE* infile;
char vcode[2];
char temp[2];
int value;
infile = fopen("Vaccine.txt", "r"); // file opening for reading
//getting the vaccine code from user through keyboard to search
printf("Enter Vaccine Code to explore : ");
scanf("%s", vcode);
if (infile == NULL) // checking for file existence
{
printf("Vaccine.txt file unfamiliar\n");
}
strcpy(temp, vcode);
//Reading the file
while (fscanf(infile, "%s %s %s %d %f\n", vaccinename, vaccinecode, country, &dosage, &populaion) != EOF)
{
//checking user entered vaccine code and available in the file is same
if (vaccinecode[0] == temp[0] && vaccinecode[1] == temp[1])
{
// Printing the matched record
printf("%15s\t%2s\t%15s\t%6s\t%10s\n", "Vaccine Name", " Vaccine Code", "Country", "Dosage", "Population");
printf("%15s\t%13s\t%15s\t%d\t%3.2f\n", vaccinename, vaccinecode, country, dosage, populaion);
}
}
fclose(infile); // closing the file
}//end
![Enter Dosage Required : 1
Enter Population Covered : 12.00
press 1 to pursue and 0 to exit : 1
Enter Vaccine Name : Sinovac
Enter Vaccine Code : SV
Enter Counry Name : China
Enter Dosage Required : 3
Enter Population Covered : 50.00
press 1 to pursue and 0 to exit : 1
Enter Vaccine Name : AstraZenea
Enter Vaccine Code : AZ
Enter Counry Name : UK
Enter Dosage Required : 1
Enter Population Covered : 15.00
press 1 to pursue and 0 to exit : 1
Enter Vaccine Name : Sputnikv
Enter Vaccine Code : SP
Enter Counry Name : Russia
Enter Dosage Required : 3
Enter Population Covered : 10.10
press 1 to pursue and 0 to exit : 1
Enter Vaccine Name : CansinoBio
Enter Vaccine Code : CS
Enter Counry Name : China
Enter Dosage Required : 2
Enter Population Covered : 10.00
press 1 to pursue and 0 to exit : 0
Vaccine Name Vaccine Code
Country Dosage Population
Pfizer
PF
USA 1
12.00
Sinovac
SV
China 3
50.00
AstraZenea
AZ
UK 1
15.00
Sputnikv
SP
Russia 3
10.10
CansinoBio
CS
China 2
10.00
Enter Vaccine Code to explore : AZ
Vaccine Name Vaccine Code
Country Dosage Population
Astrazenea
AZ
UK 1
15.00
...Program finished with exit code o
Press ENTER to exit console.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F6ebbc516-7ad4-45ee-a216-39476d64af88%2Fc73fbac9-e0c1-43e0-893e-2303baf48ade%2Ff1wg5vg_processed.jpeg&w=3840&q=75)
![Name of Vaccine Vaccine Code Producing Country Dosage Required Population Covered (%)
Pfizer
PF
USA
50
Sinovac
SV
China
18.8
AstraZeneca
AZ
UK
2
10
Sputnik V
SP
Russia
10
CanSinoBio
CS
China
1
10.9](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F6ebbc516-7ad4-45ee-a216-39476d64af88%2Fc73fbac9-e0c1-43e0-893e-2303baf48ade%2Fxyun7ax_processed.jpeg&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 2 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Operations Research : Applications and Algorithms](https://www.bartleby.com/isbn_cover_images/9780534380588/9780534380588_smallCoverImage.gif)
![C++ Programming: From Problem Analysis to Program…](https://www.bartleby.com/isbn_cover_images/9781337102087/9781337102087_smallCoverImage.gif)
![Systems Analysis and Design (Shelly Cashman Serie…](https://www.bartleby.com/isbn_cover_images/9781305494602/9781305494602_smallCoverImage.gif)
![Operations Research : Applications and Algorithms](https://www.bartleby.com/isbn_cover_images/9780534380588/9780534380588_smallCoverImage.gif)
![C++ Programming: From Problem Analysis to Program…](https://www.bartleby.com/isbn_cover_images/9781337102087/9781337102087_smallCoverImage.gif)
![Systems Analysis and Design (Shelly Cashman Serie…](https://www.bartleby.com/isbn_cover_images/9781305494602/9781305494602_smallCoverImage.gif)
![Management Of Information Security](https://www.bartleby.com/isbn_cover_images/9781337405713/9781337405713_smallCoverImage.gif)